2017-09-13 20 views
0

我是VBA Excel的新手。我想写的是在B列中对齐列的数据给然后删除空行左 我的数据示例如下代码:在excel中对齐两列中的数据VBA

Unsorted Data

所需的输出看起来是这样的。

Sorted Data

+0

https://stackoverflow.com/questions/9379673/excel-vba-delete-empty-rows – Unknown

回答

1

假设数据如下

enter image description here

然后试试下面的代码

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 

变化范围内,按您的数据。这会给结果作为

enter image description here

+0

完美的作品! – WanjauSam