Sub 仅汇总()
Dim Cn As Object, StrSQL$, Sht As Worksheet, Field$
Field = "F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,F13,F14,F15,F16,F17,F18,F19,F20,F21,F22,F23,F24,F25,F26,F27,F28,F29"
Set Cn = CreateObject("Adodb.Connection")
Cn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Extended Properties='Excel 12.0;HDR=NO';Data Source=" & ThisWorkbook.FullName
For Each Sht In Worksheets
If IsNumeric(Sht.Name) Then
StrSQL = StrSQL & " Union All Select " & Field & " From [" & Sht.Name & "$A5:AC] Where F3 <> "" "
End If
Next Sht
Sheets("仅汇总").Range("A2").CopyFromRecordset Cn.Execute(Mid(StrSQL, 12))
End Sub
借鉴的某大神的代码修改成自己需要的运行后,仅1357911汇总了,这是怎么回事?
|