0

I'm new to VBA Excel. I wanted to write a code that aligns data in Column A to that in Column B then deletes the empty rows left My Data example is as follows:

Unsorted Data

Desired output looks like this.

Sorted Data

Community
  • 1
  • 1
WanjauSam
  • 15
  • 5

1 Answers1

1

Assuming data is as follows

enter image description here

then try the following code

Sub Demo()
    With ThisWorkbook.Worksheets("Sheet7")  'change Sheet7 to your data sheet
        .Range("A1:B23").Cells.SpecialCells(xlCellTypeBlanks).Delete Shift:=xlUp
    End With
End Sub

Change range as per your data. This will give result as

enter image description here

Mrig
  • 11,612
  • 2
  • 13
  • 27