0

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!

1 Answer 1

2

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
Sign up to request clarification or add additional context in comments.

6 Comments

Thanks for your response. That's very close. But it only selects the cells in column H, not the entire row.
Okay, here's what I changed: Sub Zeros() Dim i As Long: i = 2 Dim r As Long: r = 1 Do While Range("H" & i).Value = 0 i = i + 1 Loop Rows(r & ":" & i - 1).Select End Sub
How do I do a carriage return in the comments? Everytime I hit enter it saves the comment instead of going to the next line.
you can't do it in comments, you will need to post an answer, your code (based on my mine) works, also check my edited code Range("H1:H" & i - 1).EntireRow.Select. Please mark the question as answered if you are satisfied with the reply
I like yours better. Thanks
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.