title: VBA Excel Merging of Cells based on a Specific cell value
body: <p>I would like to automate the merging of cells based by column for multiple columns based on the information in a specific column.</p>
  
  <p>Based on the below picture the values in column c will determine the number of rows that need to be merged together for Columns A through K. With each change in the value in Column C - the merging would begin again.</p>
  
  <p><a href="https://i.stack.imgur.com/4gqZT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4gqZT.png" alt="enter image description here"></a></p>
  
  <pre><code>Private Sub MergeCells_C() 
      Application.ScreenUpdating = False 
      Application.DisplayAlerts = False 
      Dim rngMerge As Range, cell As Range 
      Set rngMerge = Range("C1:C1000") 'Set the range limits here 
  
  MergeAgain: 
  
      For Each cell In rngMerge 
          If cell.Value = cell.Offset(1, 0).Value And IsEmpty(cell) = False Then 
              Range(cell, cell.Offset(1, 0)).Merge 
              GoTo MergeAgain 
          End If 
      Next 
  
      Application.DisplayAlerts = True 
      Application.ScreenUpdating = True 
  End Sub
  </code></pre>