|
这段代码是写在EXCEL里的。有些问题能帮我改一改吗?
Sub ZHP正式系列()
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")
ING1 = Application.ActiveCell.Column
For xh = 1 To 100
If Cells(1, xh) = "型号" 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 = Nz(DLookup("[正式系列]", "ZHP", "[ZPXHAO]='" & Va & "'")) '程序在这有时错误,有时可以运行
Cells(Row, ING1) = Strsql
Next
退出:
Set DB = Nothing
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Exit Sub
err:
MsgBox Error$
Resume 退出:
End Sub |
|