title: VBA formatting table with merged cells
body: <p>I've got a function which merges cells in table if whole range has the same value (eg. if A1:G1 is equal to A2:B2 it will merge cells like A1&amp;A2, B1&amp;B2 etc. More here: <a href="https://stackoverflow.com/questions/55237775/how-to-check-if-two-ranges-value-is-equal">How to check if two ranges value is equal</a>)
  Now I would like, to change color on table created by that funcion, like first row (doesn't matter if merged or no) filled with color, second blank etc. but I have no idea whether I should color it with merging function or create another which will detect new table with merged rows as one etc. Below is my code:</p>
  
  <pre><code>Sub test()
  
      Dim i As Long, j As Long, k As Long, row As Long
      row = Cells(Rows.Count, 2).End(xlUp).row
      k = 1
      For i = 1 To row Step 1
          If Cells(i, 1).Value = "" Then Exit For
          If Join(Application.Transpose(Application.Transpose(Range(Cells(i, 1), Cells(i, 3)))), Chr(0)) &lt;&gt; Join(Application.Transpose(Application.Transpose(Range(Cells(i + 1, 1), Cells(i + 1, 3)))), Chr(0)) Then
            If i &lt;&gt; k Then
              For j = 1 To 3 Step 1
                    Application.DisplayAlerts = False
                    Range(Cells(i, j), Cells(k, j)).Merge
                    Application.DisplayAlerts = True
              Next j
            End If
          k = i + 1
          End If
      Next i
  End Sub 
  </code></pre>