I’ve got 3 heavy tables of 150x1300 cells. Table1, Table2, Table3. They look the same.
I need to check if any cell of Table1 differs from the same cell in Table2, then put the difference in the same cell in Table3.
How should I do this with the maximum performance?
You can do it with VBA code quite easily.
Option Explicit Sub CompareWorksheets() Dim varSheetA As Variant Dim varSheetB As Variant Dim strRangeToCheck As String Dim iRow As Long Dim iCol As Long strRangeToCheck = "A1:B4" ' If you know the data will only be in a smaller range, reduce the size of the ranges above. Debug.Print Now varSheetA = Worksheets("Sheet1").Range(strRangeToCheck) varSheetB = Worksheets("Sheet2").Range(strRangeToCheck) ' or whatever your other sheet is. Debug.Print Now For iRow = LBound(varSheetA, 1) To UBound(varSheetA, 1) For iCol = LBound(varSheetA, 2) To UBound(varSheetA, 2) If varSheetA(iRow, iCol) = varSheetB(iRow, iCol) Then ' Cells are identical. ' Do nothing. Else ' Cells are different. ' Code goes here for whatever it is you want to do. MsgBox "Cells are different, do something" End If Next iCol Next iRow End Sub
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.