|
本帖最后由 一指禅62 于 2012-8-17 10:37 编辑
- Sub 数据汇总()
- Dim cnn As Object, sql$, Sh As Worksheet
- Set cnn = CreateObject("ADODB.Connection")
- cnn.Open "Provider=Microsoft.Jet.Oledb.4.0;Extended Properties =Excel 8.0;Data Source= " & ThisWorkbook.FullName
- Range("A8:M65536").ClearContents
- For Each Sh In Worksheets
- If Sh.Name <> "汇总" Then sql = sql & "select * from [" & Sh.Name & "$] union all "
- Next
- sql = "select 证件号码(唯一),姓名, sum(基本工资),sum(效益工资),sum(合计) from (" _
- & Left(sql, Len(sql) - 11) & ") group by 证件号码(唯一),姓名 "
- Range("A8").CopyFromRecordset cnn.Execute(sql)
- cnn.Close: Set cnn = Nothing
- End Sub
复制代码 对本工作簿内工作表名称不是“汇总”的工作表汇总,要求这些工作表格式相同
|
评分
-
1
查看全部评分
-
|