|
这是个EXCEL的模块,请高手帮我改一下,不知为什么出错
Sub 系列()
On Error GoTo 错误_Err
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Dim DB As Database
Dim RS As Recordset
Dim Va As String
Dim Strsql As String
Set DB = OpenDatabase("D:\数据库\数据库.MDB")
Set RS = DB.OpenRecordset("部品")
ING1 = Application.ActiveCell.Column
For xh = 1 To 100
If UCase(Cells(1, xh)) = "HINBAN" Or Cells(1, xh) = "型号" Or Right(Cells(1, xh), 2) = "型号" Then ing2 = xh: Exit For
Next
row_e = Cells(65536, ing2).End(xlUp).Row
For Row = 2 To row_e
Va = Cells(Row, ing2)
Strsql = DLookup("[系列]", "部品", "[型号]='" & Va & "'") 执行到这就出错
Cells(Row, ING1) = Strsql
Next
退出:
Set RS = Nothing
Set DB = Nothing
Application.DisplayAlerts = true
Application.ScreenUpdating = true
Exit Sub
错误_Err:
MsgBox Error$
Resume 退出:
End Sub |
|