ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Finding a row number (https://www.excelbanter.com/excel-programming/344580-finding-row-number.html)

jnasr00

Finding a row number
 

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.


--
jnasr00
------------------------------------------------------------------------
jnasr00's Profile: http://www.excelforum.com/member.php...o&userid=28515
View this thread: http://www.excelforum.com/showthread...hreadid=481723


Rowan Drummond[_3_]

Finding a row number
 
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

jnasr00 wrote:
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.



Gary Keramidas

Finding a row number
 
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

--


Gary


"jnasr00" wrote in
message ...

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.


--
jnasr00
------------------------------------------------------------------------
jnasr00's Profile:
http://www.excelforum.com/member.php...o&userid=28515
View this thread: http://www.excelforum.com/showthread...hreadid=481723





All times are GMT +1. The time now is 12:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com