我想检查工作簿中多个单元格的匹配字符串值到另一个工作簿中的行。我写了这段代码,但它没有完成这个任务。
行,第一个问题FS,r1 var在运行代码时分配为空,而匹配语句则没有达到目标。如果有任何方法可以实现,我需要帮助。
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 multiple 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
End Sub
enter image description here enter image description here enter image description here