找不到运行时错误-2147221080(800401a8)

时间:2018-05-29 12:07:11

标签: excel-vba vba excel

我需要帮助才能对此代码进行故障排除,以查找多个工作表中的客户是否存在于另一个工作簿的CUSTOMER LIST中,但我遇到了运行代码时出现“自动化错误”的问题

Sub checkcustomerID()

On Error Resume Next

Dim y As Workbook
Dim x As Workbook

Set y = ActiveWorkbook
Set x = Workbooks.Open("\\Eng_badia-pc\e\WALEED SOBEH ENGINEERING OFFICE\W-01-ADMINSTRATIVE DEPARTMENT\W-01-AD-1-SALES\W-01-D1-S1-STATMENTS\03-PROJECTS TRACKER.xlsm")

'--------------------------------------  'Inspect matching of values of multible cells in _
                                          workbook1 to row in another workbook

For i = 1 To y.Sheets.Count
For j = 1 To x.Sheets.Count

FS1 = y.Sheets(i).Range("b3").Value
FS2 = y.Sheets(i).Range("b6").Value
FS3 = y.Sheets(i).Range("e6").Value
FS4 = y.Sheets(i).Range("h6").Value
FS5 = y.Sheets(i).Range("b7").Value
FS6 = y.Sheets(i).Range("h7").Value
FS7 = y.Sheets(i).Range("e7").Value

R1 = x.Sheets(j).Range("d:d").Value
R2 = x.Sheets(j).Range("m:m").Value
R3 = x.Sheets(j).Range("n:n").Value
R4 = x.Sheets(j).Range("o:o").Value
R5 = x.Sheets(j).Range("p:p").Value
R6 = x.Sheets(j).Range("q:q").Value
R7 = x.Sheets(j).Range("r:r").Value

If FS1 = R1 And FS2 = R2 And FS3 = R3 And _
FS4 = R4 And FS5 = R6 And FS6 = R6 And FS6 = R6 Then

MsgBox "The Customer " & "" & x.Sheets(j).Range("d" & j) & "and have Customer ID:" & x.Sheets(j).Range("b" & j)

Sheets(i).Names = x.Sheets(j).Range("b" & j + 3)

Else:

MsgBox "New Customer "

End If

Next j

Next i

0 个答案:

没有答案
相关问题