I have the following code:
<
>>> use code - tags <<<
/>
I want to look for a number (that's in sheet1 column B) in Sheet(2) in column A or column B.
<
/>
Always returns nothing which is incorrect 'cause every row in Sheet1 has a match in sheet 2.
What am I doing wrong?
Thanks for any help
<
>>> use code - tags <<<
Code:
Sub find_match()
Dim I, total, fRow As Integer
Dim found As Range
total = Sheets(1).Range("B" & Rows.Count).End(xlUp).Row
For I = 2 To total
answer1 = Worksheets(1).Range("B" & I).Value
Set found = Sheets(2).Range("A2:B" & Sheets(2).Cells(Sheets(2).Rows.Count).End(xlUp).Row).Find(what:=answer1) 'finds a match
If found Is Nothing Then
Worksheets(1).Range("P" & I).Value = "NO MATCH"
GoTo NextIteration
End If
If IsNumeric(Sheets(2).Cells(found.Row, 1).Value) And IsNumeric(Sheets(2).Cells(found.Row, 2).Value) Then
Sheets(1).Rows("I:I").Copy
Sheets("Complaints Common").Paste
Else
Sheets(1).Rows("I:I").Copy
Sheets("Complaints not Common").Paste
End If
NextIteration:
Next I
End Sub
I want to look for a number (that's in sheet1 column B) in Sheet(2) in column A or column B.
<
Code:
Set found = Sheets(2).Range("A2:B" & Sheets(2).Cells(Sheets(2).Rows.Count).End(xlUp).Row).Find(what:=answer1) 'finds a match
Always returns nothing which is incorrect 'cause every row in Sheet1 has a match in sheet 2.
What am I doing wrong?
Thanks for any help
Last edited by a moderator: