Excel VBA删除范围内的空白行 [英] Excel VBA to delete blank rows within a range
本文介绍了Excel VBA删除范围内的空白行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个工作表,数据从A84开始,一直扩展到X列.我使用此VBA选择整个数据范围.
I have worksheet that have data starting at A84, extending to column X. I use this VBA to select the entire range of data.
Dim Lastrow As Integer
Lastrow = Range("A:Z").Find("*", , , , xlByRows, xlPrevious).Row
Range("A84:X" & Lastrow).Select
在该选定范围内,我需要它来检测A至Z列中哪些行为空白并将其删除.如果Z列之后有数据,则应删除该行,因为我认为该列为空.
Within that selected range, I need it to detect which rows are blank from columns A to Z and delete them. If there's data after column Z, the row should be deleted because I'm considering it blank.
推荐答案
注释有时会添加字符.这是代码:
The comments sometimes adds characters. Here is the code:
Dim Lastrow As Integer
Lastrow = Range("A:Z").Find("*", , , , xlByRows, xlPrevious).Row
For i = Lastrow To 84 Step -1
If Application.CountA(Range(Cells(i, 1), Cells(i, 26))) = 0 Then Rows(i).Delete
Next i
这篇关于Excel VBA删除范围内的空白行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文