Hi all,
I am looking for a way to have a macro look in the current workbook (not a specific one, but the one that is open at the moment) to look for values that aren't in another workbook. I have the following code which works for a specific workbook, but instead of "List Copy" I want the macro to compare whatever file is open now. It will most likely be the List Copy with a different date.
Sub colorlist()
Dim SearchRange As Range
Dim NUmberRange As Range
Dim Searchvalue As String
Dim xCell As Variant
Dim c As Range
'Where is the search list?
Set SearchRange = Workbooks("Bill of mat.xlsm").Worksheets("Database").Range("A2:A5000")
'Where is list of numbers?
Set NUmberRange = Workbooks("List Copy.xlsm").Worksheets("Sheet1").Range("E2:E100000")
For Each c In NUmberRange
Searchvalue = c.Value
On Error Resume Next
Set xCell = SearchRange.Find(what:=Searchvalue, matchbyte:=False)
On Error GoTo 0
If xCell Is Nothing Then
c.Interior.ColorIndex = 3
Else
c.Interior.ColorIndex = 0
End If
Next c
ActiveSheet.Range("$A$1:$Z$65745").AutoFilter Field:=5, Criteria1:=RGB(255 _
, 0, 0), Operator:=xlFilterCellColor
End Sub
Bookmarks