|
Sub demo()
Rows("1:2000").Delete Shift:=xlUp
cnn = "OLEDB;Provider=Microsoft.Ace.oledb.12.0;extended properties='excel 12.0;HDR=yes';data source=" & ThisWorkbook.FullName
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=cnn, Destination:=Range("$a$1")).QueryTable
.CommandText = "select bom.订单编码,bom.订单名称,xuqiu.* from bom inner join xuqiu on bom.材料编码=xuqiu.材料编码"
.ListObject.DisplayName = "表1"
.Refresh BackgroundQuery:=False
End With
ActiveSheet.ListObjects("表1").Unlist
For i = 4 To 40
Cells(1, i) = Format(Val(Cells(1, i)), "mm-dd")
Next
ActiveSheet.Cells.EntireColumn.AutoFit
End Sub
|
|