How to check if two ranges value is equal
I want to merge cells in columns, if there is the same value in whole row. Eg. If A1:G1 range is the same as A2:G2 I want to merge A1:A2 cells, B1:B2 to G1:G2. With my code below I get run time error 13: type mismatch. I'm assuming, that problem is with checking equality of two ranges. Dim i As Long, j As Long, row as Long row = Cells(Rows.Count, 6).End(xlUp).row For i = row To 7 Step -1 If Range(Cells(i, 7), Cells(i, 24)).Value = Range(Cells(i - 1, 7), Cells(i - 1, 24)).Value Then For j = 7 To 24 Step 1 Range(Cells(i, j), Cells(i - 1, j)).Merge Next j End If Next i The question is, how to