I have two columns from 2 worksheets. In the first worksheet a column contains a list of project names that is active. The second worksheet contains just a list of ptoject names. I need to compare the project names from the first worksheet and highlight a cell if its value does match with wildcard value in the second sheet. I have this code that compare and hightlight the exact value but what I need is to compare it using wildcard. Thanks in advance.
Code:
Sub CompareAndHighlight()
Dim rng1 As Range, rng2 As Range, i As Integer, j As Integer
Dim isMatch As Boolean
' sheet/values to be highlighted
For i = 2 To Sheets("Sheet").Range("D" & Rows.Count).End(xlUp).Row
isMatch = False
Set rng1 = Sheets("Sheet1").Range("D" & i)
' lookup sheet
For j = 1 To Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Row
Set rng2 = Sheets("Sheet2").Range("A" & j)
If StrComp(Trim(rng1.Text), Trim(rng2.Text), vbTextCompare) = 0 Then
isMatch = True
Exit For
End If
Set rng2 = Nothing
Next j
' highlight color
If isMatch Then
rng1.Interior.Color = RGB(128, 128, 128)
End If
Set rng1 = Nothing
Next i
End Sub