I am trying find matches in the A columns of two worksheets in two separate workbooks but I am coming across the above runtime error with the line "Set wb1 = Workbooks(w1)" highlighted, what am I doing wrong? I've been trying to get this going for a couple of days (insert forehead slap emoji lol) so any advice will be greatly appreciated.
Dim w1 As String, w2 As String
Dim wb1 As Workbook, wb2 As Workbook
Dim ws1 As Worksheet, ws2 As Worksheet
Dim cl As Range, ws1Rng As Range, ws2Rng As Range, aCell As Range
Dim lRowW1 As Long, lRowW2 As Long
Dim lastRowWb1 As Long
Dim lastRowWb2 As Long
Dim aVal As Object
Dim bVal As Object
w1 = "C:\Users\Desktop\Scrapes\" & x & ".xlsm"
w2 = "C:\Users\Desktop\Scrapes\" & y & ".xlsm"
Set wb1 = Workbooks(w1)
Set wb2 = Workbooks(w2)
Set ws1 = wb1.Sheet1("NewHighs")
Set ws2 = wb2.Sheet1("NewHighs")
lastRowWb1 = ws1.Range("A1").CurrentRegion.Rows.Count
lastRowWb2 = ws2.Range("A1").CurrentRegion.Rows.Count
For Each aVal In ws1.Range("A2", ws1.Range("A" & lastRowWb1))
For Each bVal In ws2.Range("A2", ws2.Range("A" & lastRowWb2))
If aVal = bVal Then
MsgBox aVal
End If
Next
Next