Michael72688
Michael72688

Reputation: 41

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!

Upvotes: 0

Views: 16109

Answers (1)

Jeanno
Jeanno

Reputation: 2859

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

Upvotes: 2

Related Questions