Sub 良率查询() Dim sh As String Dim sql$ Dim N As Byte Const nm = "产品良率查询"
Application.ScreenUpdating = False Range("a4:aa65536").ClearContents sh = Dir(ThisWorkbook.Path & "\sqldata\*.xls") While Not Len(sh) = 0 N = 1 With CreateObject("ADODB.CONNECTION") .Provider = "microsoft.jet.oledb.4.0" .ConnectionString = "Extended Properties='Excel 8.0;hdr=yes';" & "data source=" & ThisWorkbook.Path & "\sqldata\" & sh .Open sql = "select * from [Sheet" & N & "$a1:aa65536] where 订单号=" & [b1].Value [a65536].End(xlUp).Offset(1).CopyFromRecordset .Execute(sql) .Close End With sh = Dir() Wend Application.ScreenUpdating = True End Sub
Sub 良率查询() Dim sh As String Dim sql$ Dim N As Byte Const nm = "产品良率查询"
Application.ScreenUpdating = False Range("a4:aa65536").ClearContents sh = Dir(ThisWorkbook.Path & "\sqldata\*.xls") While Not Len(sh) = 0 N = 1 With CreateObject("ADODB.CONNECTION") .Provider = "microsoft.jet.oledb.4.0" .ConnectionString = "Extended Properties='Excel 8.0;hdr=yes';" & "data source=" & ThisWorkbook.Path & "\sqldata\" & sh .Open sql = "select * from [Sheet" & N & "$a1:aa65536] where 订单号=" & [b1].Value [a65536].End(xlUp).Offset(1).CopyFromRecordset .Execute(sql) .Close End With sh = Dir() Wend Application.ScreenUpdating = True End Sub
Sub 良率查询() Dim sh As String Dim sql$ Dim N As Byte Const nm = "产品良率查询"
Application.ScreenUpdating = False Range("a4:aa65536").ClearContents sh = Dir(ThisWorkbook.Path & "\sqldata\*.xls") While Not Len(sh) = 0 N = 1 With CreateObject("ADODB.CONNECTION") .Provider = "microsoft.jet.oledb.4.0" .ConnectionString = "Extended Properties='Excel 8.0;hdr=yes';" & "data source=" & ThisWorkbook.Path & "\sqldata\" & sh .Open sql = "select * from [Sheet" & N & "$a1:aa65536] where 产品名称=" & [b1].Value [a65536].End(xlUp).Offset(1).CopyFromRecordset .Execute(sql) .Close End With sh = Dir() Wend Application.ScreenUpdating = True End Sub