|
- Private Sub Worksheet_Change(ByVal Target As Range) '看图而写,未经测试
- If Intersect(Target, Range("A1").CurrentRegion.Resize(, 2)) Is Nothing Then Exit Sub
- Dim posRow As Long, Conn As Object, SQL As String
- posRow = Target.Row
- Set Conn = CreateObject("ADODB.Connection")
- Conn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & ThisWorkbook.Path & "\神马Access文件.accdb"
- SQL = "SELECT 单价 FROM [" & Cells(posRow, 1).Value & "] WHERE 材料名称='" & Cells(posRow, 2).Value & "'"
- Cells(posRow, 3).CopyFromRecordset Conn.Execute(SQL)
- Conn.Close
- Set Conn = Nothing
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|