Delete Blank Rows After Data When The Worksheet Va

2019-09-07 01:49发布

I have an excel worksheet where I have sorted into date order and this leaves an awful lot of blanks at the bottom of the spreadsheet which I would like to delete but leave the final two. (the one at the very bottom is formatted blue to the height of 6 and the one just above is blank and also to the height of 6).

The data is stored from A5 to J and varies in length - tab name is Date Order

Does anyone know of any VBA code that will help with this problem.

Any help would be greatly appreciated.

1条回答
来,给爷笑一个
2楼-- · 2019-09-07 02:05

This does the trick if anyone wants the code however it does not leave the last two rows does anyone know how to achieve this?

' This macro deletes all rows on the active worksheet
' that have no value in column A.
Dim iRow As Long
Dim LastRow As Long
LastRow = ActiveSheet.UsedRange.Rows.Count + ActiveSheet.UsedRange.Row - 1
For iRow = LastRow To 1 Step -1
If Cells(iRow, 1) = "" Then Rows(iRow).Delete
Next iRow
查看更多
登录 后发表回答