|
Private Sub CommandButton1_Click()
Dim cnADO, rsADO As Object
Dim strPath, strTable, strSQL As String
aa = Sheet1.Cells(2, 2)
Sheet1.Range("a7:k1000") = ""
Set cnADO = CreateObject("ADODB.Connection")
cnADO.Open "Provider=Microsoft.ACE.OLEDB.12.0;Extended Properties='excel 12.0;hdr=yes;imex=1';;data source=" & ThisWorkbook.FullName
strSQL = "select * from [数据表$a1:k1000] where 存区 like '%" & aa & "%' or 规格型号 like '%" & aa & "%' "
Sheet1.Cells(7, 1).CopyFromRecordset cnADO.Execute(strSQL)
cnADO.Close
Set cnADO = Nothing
End Sub
Sub zz()
Dim cnADO, rsADO As Object
Dim strPath, strTable, strSQL As String
aa = Sheet1.Cells(2, 2)
Sheet1.Range("a7:o1000") = ""
Set cnADO = CreateObject("ADODB.Connection")
cnADO.Open "Provider=Microsoft.ACE.OLEDB.12.0;Extended Properties='excel 12.0;hdr=yes;imex=1';;data source=" & ThisWorkbook.FullName
strSQL = "select * from [数据表$a1:o1000] where 物料名称 like '%" & aa & "%' or 规格型号 like '%" & aa & "%' "
Sheet1.Cells(7, 1).CopyFromRecordset cnADO.Execute(strSQL)
cnADO.Close
Set cnADO = Nothing
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$B$1" Or Target.Address = "$B$2" Then
zz
End If
End Sub
楼主可以帮我译一下这两段代码各条语句的涵义 我是个新小白 拜托了 在这先谢谢了
|
|