Delete Blank Rows After Data When The Worksheet Varies In Length

大城市里の小女人 提交于 2020-01-17 12:48:11

问题


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:


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


来源:https://stackoverflow.com/questions/21739115/delete-blank-rows-after-data-when-the-worksheet-varies-in-length

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!