ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how to extract the row number of a cell with certain value (https://www.excelbanter.com/excel-programming/304140-how-extract-row-number-cell-certain-value.html)

houston city

how to extract the row number of a cell with certain value
 
Hi, I am trying to extract the row number of a cell with a particular
value. For example, I have a cell with the value '1-A54' in it, and I
am trying to get the row number where this value appear. Can anybody
tell me how to write it in VBA? Thanks a lot.



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Always Learning

how to extract the row number of a cell with certain value
 
Hi There,
Think this will work. Just from memory so please forgive me if I have missed
something.

Dim RowNum As Integer
Dim ColNum as Integer
Dim RowFoundOn as Integer
Dim ImFinished as Boolean

RowNum = 0
ColNum = 1 '*** set to column A, change to the column containing values
you are searching for.
Do
RowNum = RowNum + 1
Cells(RowNum,ColNum).Select
If Cells(RowNum,ColNum).Value = "1-A54"
RowFoundOn = ActiveCell.Row
ImFinished = True
End If
Loop Until ImFinished

All the best,

Steve Wilson.


"houston city" wrote in message
...
Hi, I am trying to extract the row number of a cell with a particular
value. For example, I have a cell with the value '1-A54' in it, and I
am trying to get the row number where this value appear. Can anybody
tell me how to write it in VBA? Thanks a lot.



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!




Frank Kabel

how to extract the row number of a cell with certain value
 
Hi
one way:
msgbox application.match("1-A54",Range("A1:A1000"),0)

or use the Find method (see VBA help for an example)

-----Original Message-----
Hi, I am trying to extract the row number of a cell with

a particular
value. For example, I have a cell with the value '1-A54'

in it, and I
am trying to get the row number where this value appear.

Can anybody
tell me how to write it in VBA? Thanks a lot.



*** Sent via Developersdex http://www.developersdex.com

***
Don't just participate in USENET...get rewarded for it!
.



All times are GMT +1. The time now is 02:03 AM.

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