当工作表长度变化后,删除数据后的空白行 [英] Delete Blank Rows After Data When The Worksheet Varies In Length

查看:144
本文介绍了当工作表长度变化后,删除数据后的空白行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个excel工作表,我已经按照日期顺序进行排序,这样在电子表格的底部留下了很多空白,我想删除,但要留下最后两个。 (最底端的格式为蓝色,高度为6,上面的空格为空白,高度为6 )。



数据从 A5 存储到 J ,长度不同 - 标签名称为

任何帮助将不胜感激。

解决方案

如果有人想要代码,但是它不会离开最后两行有谁知道如何实现这一点?

 '此宏删除活动工作表上的所有行
'在列A中没有任何值。
Dim iRow As Long
Dim LastRow As Long
LastRow = ActiveSheet.UsedRange.Rows.Count + ActiveSheet.UsedRange.Row - 1
对于iRow = LastRow到1步-1
如果Cells(iRow,1)=然后Rows(iRow).Delete
下一步iRow


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.

解决方案

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

这篇关于当工作表长度变化后,删除数据后的空白行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆