title: Unmerge, Sort and Merged cells in vba
body: <p>I am working with the excel-vba, I have to sort the rows in ascending order  with merged cells, I know that the merged cell cannot be sorted that is why, this work around is the only solution to my problem. I need to unmerged the cells then copy the value of the first cell and paste it to the second cell, after that, the code will sort the list using the A column and C column. and then after that if the A and C column has an equal value, it will turn to merged cell.</p>
  
  <p>I hope someone could help me with this project.</p>
  
  <p>Also view this image to see the list.</p>
  
  <p><a href="https://i.stack.imgur.com/SuH5v.png" rel="nofollow noreferrer">Sort</a></p>
  
  <p>So, I constructed a code that will do this process but it cant.</p>
  
  <pre><code>    Sub Sort()
      On Error GoTo myErr
      Dim myRange As Range
      Dim lstrow As Long
      Dim i As Integer
      Dim cel As Range
  
      Set myRange = Sheet1.Range("A2:C7")
      lstrow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Row
  
      With myRange
  
      .UnMerge
      For Each cel In myRange
              If IsEmpty(cel) Then
                  For i = 2 To lstrow
                     ' cel(i).Value = 1
                     Sheet1.Range(i).Copy Sheet1.Range(cel).PasteSpecial
                     Sheet1.Range("C3").CurrentRegion.Sort _
                     key1:=Sheet1.Range("C3"), order1:=xlAscending, _
                     Header:=xlGuess
  
                          Next i
               End If
  
              Next cel
  
  
  
  
      End With
  
      myErr:
      MsgBox "Unble to sort!"
      End Sub
  </code></pre>
  
  <blockquote>
    <p>“No one is useless in this world who lightens the burdens of another. -Charles Dickens”</p>
  </blockquote>
  
  <p>Regards,</p>