So, I'm learning VBA and am trying to get this code to run through column Q starting from row 3 of Sheet 1, and compare its results with column F starting from row 4 of Sheet 2. If true, highlight the offending cell with yellow (I'd rather highlight the entire row, if you could help with that, it'd be fantastic!).
Sub CompareValues()
Set ws1 = Application.Workbooks("Book1.xlsx").Sheets("Sheet1")
Set ws2 = Application.Workbooks("Book2.xls").Sheets("Sheet2") ' the xls is correct
startRow = 3
ws1Value1Col = "Q"
ws1EndRow = ws1.UsedRange.Rows(ws1.UsedRange.Rows.Count).Row
ws2Value1Col = "F"
ws2EndRow = ws2.UsedRange.Rows(ws2.UsedRange.Rows.Count).Row
For i = startRow To ws1EndRow
If Not ws1.Cells(i, ws1Value1Col).Value = ws2.Cells(i + 1, ws2Value1Col).Value Then
wsl.Cells(i, ws1Value1Col).Value = vbYellow
End If
Next
End Sub
I'm getting error 424: Object required.
After googling for the past hour I am not any closer to solving this. I've tried multiple suggestions to no avail. Both workbooks and worksheets are open at runtime.