Leveraging the post here, I was able to build a VBA macro to compare cells between worksheets to suit my purposes. However, until now, I didn't test it with a range that doesn't start at A1.
When giving a range like B1:X50, I encounter an issue where the LBound of the column dimension of the sheet array is 1 while the column at the start of the given range is 2 (B). Here's a portion of the code I'm working with:
'Define the range to be checked
strRangeToCheck = Summary_ws.Range("I2").Value
'Store the range to be checked on each sheet in an array
varSheetA = New_Data_ws.Range(strRangeToCheck)
varSheetB = Old_Data_ws.Range(strRangeToCheck)
'Clear current highlighted cells on data tabs
New_Data_ws.Cells.Interior.Color = xlNone
Old_Data_ws.Cells.Interior.Color = xlNone
'Initialize counter
Counter = 0
Counter_rng.Value = Counter
For iRow = LBound(varSheetA, 1) To UBound(varSheetA, 1)
For iCol = LBound(varSheetA, 2) To UBound(varSheetA, 2)
On Error GoTo Err_Handler
If IsError(New_Data_ws.Cells(iRow, iCol).Value) Or IsError(Old_Data_ws.Cells(iRow, iCol).Value) Then
Counter = Counter + 1
Error_Flag = True
Call Flag_Changes
ElseIf varSheetA(iRow, iCol) = varSheetB(iRow, iCol) And _
Len(varSheetA(iRow, iCol)) = Len(varSheetB(iRow, iCol)) Then
'Cells are identical and lengths match
'Do Nothing
Else 'Cells are different
Counter = Counter + 1 'increment counter
Error_Flag = False
Call Flag_Changes
End If
Next iCol
Next iRow
I'm able to evaluate the strRangeToCheck to determine if it starts at column A or not. Based on that determination, would it then be possible to manually set the LBound of the sheet to match the starting column in strRangeToCheck?