Hello people,
I have made following code,
the code check in sheet1 columns "A"and "B" then match them with sheet2 columns "A" and "B".
instead I would like the code to check if
sheet1 columns "A" and "B" cells same row values are anywhere in sheet2, instead of sheet2 "A" and "B" as long they are same row.
here is code
See my attached file
Could someone help me
thank you in advance
I have made following code,
the code check in sheet1 columns "A"and "B" then match them with sheet2 columns "A" and "B".
instead I would like the code to check if
sheet1 columns "A" and "B" cells same row values are anywhere in sheet2, instead of sheet2 "A" and "B" as long they are same row.
here is code
Code:
Sub Compare()
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim r As Long
Dim m As Long
Dim s As Long
Dim n As Long
Dim mystring As String
Dim mystringtwo As String
Dim myresult As String
Set ws1 = ActiveSheet
m = ws1.range("A" & ws1.Rows.Count).End(xlUp).Row
Set ws2 = Worksheets("sheet2")
n = ws2.range("A" & ws2.Rows.Count).End(xlUp).Row
For r = 1 To m
For s = 1 To n
If Trim(ws1.range("A" & r)) <> "" Or Trim(ws2.range("B" & r)) <> "" Then
If ws1.range("A" & r) = ws2.range("A" & s) And _
ws2.range("B" & r) = ws2.range("B" & s) Then
mystring = ws2.range("G" & s).Interior.ColorIndex = 5
mySheetStringone = ws2.range("G" & s).Text
mystring = Sheets("sheet2").range("G" & s).Text
mystringtwo = Sheets("sheet1").range("J" & s).Text
myresult = (mystring * mystringtwo)
Sheets("Sheet2").range("N" & s).Value = myresult
End If
End If
Next s
Next r
End Sub
See my attached file
Could someone help me
thank you in advance