Finding a row number

  • Thread starter Thread starter jnasr00
  • Start date Start date
J

jnasr00

Hi guys I am new to VBA and I am trying to write a macro that
allows me to search for a certain value in a cell and then delate all
the rows above that specific cell. I have written a code to find the
specific cell,
but how do I find out what row that cell is in so I can delete the ones
above it?

Is there anyway to store the row number of a selected cell in a
variable?

Your help would be much appreciated.
 
It depends on the code you have for finding the cell. If you are
assigning a range object to that cell then:
myRange.Row
If you are selecting the cell (not recommended in case the value is not
found) then:
Activecell.Row

Hope this helps
Rowan
 
not sure how you're figuring out where to start, but this would delete the
rows from row 5 to one above where the active cell is

Range(Rows(5), ActiveCell.Offset(-1, 0)).Delete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top