簡體   English   中英

Excel VBA刪除范圍內的空白行

[英]Excel VBA to delete blank rows within a range

我的工作表的數據從A84開始,擴展到X列。我使用此VBA選擇整個數據范圍。

Dim Lastrow As Integer
Lastrow = Range("A:Z").Find("*", , , , xlByRows, xlPrevious).Row

Range("A84:X" & Lastrow).Select

在選定的范圍內,我需要它來檢測A到Z列中哪些行為空白並將其刪除。 如果Z列之后有數據,則應刪除該行,因為我認為該列為空。

注釋有時會添加字符。 這是代碼:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM