简体   繁体   中英

How do I unhide all rows in VBA from the last row?

On the spreadsheet, the LastRow is actually 32, but when I run this sub, it's unhiding everything before Row 30, and leaving both 31 and 32 hidden. Any help?

Dim I As Integer
Dim LastRow As Long
LastRow = Cells(Rows.Count, 4).End(xlUp).Row
For I = 1 To LastRow
    Rows(I).EntireRow.Hidden = False
Next I

LastRow = Cells(Rows.Count, 4).End(xlUp).Row returns last visible row (with data)...

In this case will work:

ActiveSheet.UsedRange.Rows.count

Even if I never recommend using it...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM