简体   繁体   中英

VBA Excel - select all rows with value in a column

I have a spreadsheet named "Copy" sorted by numeric values (lowest to highest) in column H. The sheet has headers in row 1. The lowest value in column H is 0. I would like to find the last row that has column H equal 0 and then select the range of rows where column H equals 0 along with the header row.

Thanks!

This will do the job

Sub CustomSelect()
    Dim i As Long: i = 2
    Do While Range("H" & i).Value = 0
        i = i + 1
    Loop
    Range("H1:H" & i - 1).EntireRow.Select
End Sub

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