|
Sub limonet()
Dim Cn As Object, StrSQL$, Arr As Variant
Set Cn = CreateObject("adodb.connection")
Cn.Open "provider=microsoft.ace.oledb.12.0;extended properties='excel 12.0;HDR=NO';data source=" & ThisWorkbook.FullName
StrSQL = "select f1,sum(f2),first(f3) from [Sheet2 (2)$D4:F] where not f1 is null group by f1"
Arr = Cn.Execute(StrSQL).getrows
Range("D4:f29").ClearContents
Range("D4").Resize(UBound(Arr, 2) + 1, 3) = WorksheetFunction.Transpose(Arr)
' ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
' IgnorePrintAreas:=False
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
ThisWorkbook.Path & "\装箱清单.pdf", Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
True
End Sub |
|