在工作表1汇总本文件夹下001工作薄的表1分数列查询汇总
Set conn = CreateObject("ADODB.Connection")
conn.Open "dsn=excel files;dbq=" & ThisWorkbook.Path & "\001.xls"
sql = "select sum(分数) from [sheet1$]"
Sheets(1).[a2].CopyFromRecordset conn.Execute(sql)
conn.Close: Set conn = Nothing
End Sub
------------------------------------------
在工作表1汇总本文件夹下001工作薄的表1A1:A10查询汇总
Set conn = CreateObject("ADODB.Connection")
conn.Open "provider=microsoft.jet.oledb.4.0;extended properties='excel 8.0;hdr=no;';data source=" & ThisWorkbook.Path & "\001.xls"
sql = "select sum(f1) from [sheet1$a1:a10]"
Sheets(1).[A5].CopyFromRecordset conn.Execute(sql)
conn.Close: Set conn = Nothing