|
Sub 明细()
Dim f$
With Application.FileDialog(1)
With .Filters
.Clear
.Add "Excel(*.xls*)", "*.xls*"
End With
If .Show Then f = .SelectedItems(1) Else Exit Sub
End With
Dim Cn As Object, Sq$
Set Cn = CreateObject("ADODB.Connection")
Cn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Extended Properties=Excel 12.0;Data Source=" & f
Sq = "SELECT 凭证号码,科目,成本要素名,物料,物料描述,成本中心,冲销科目,冲销科目名,参考代码,采购文本,采购凭证,成本中心名 FROM [Sheet1$A1:L] WHERE 科目 IN('59000101')"
With Sheets("details")
.UsedRange.Offset(1).ClearContents
.[A2].CopyFromRecordset Cn.Execute(Sq)
End With
Cn.Close
Set Cn = Nothing
End Sub |
|