|
- Private Sub Worksheet_Change(ByVal Target As Range)
- If Intersect(Target, [B1:C1]) Is Nothing Then Exit Sub
- Dim Cn As Object, Sqlstr$
- Set Cn = CreateObject("Adodb.Connection")
- Cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=Excel 8.0;Data Source=" & ThisWorkbook.FullName
- Sqlstr = "Select 合同号,省份,类型,屏数,发货日期,Year(发货日期),Month(发货日期) " _
- & "From [发货清单$] " _
- & "Where 省份&类型 Like '%" & [B1] & "%" & [C1] & "%'"
- [7:65536].Delete
- [A7].CopyFromRecordset Cn.Execute(Sqlstr)
- Cn.Close: Set Cn = Nothing
- End Sub
复制代码 |
|