ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how to find row with a given value in a column (https://www.excelbanter.com/excel-programming/294086-how-find-row-given-value-column.html)

rtos[_2_]

how to find row with a given value in a column
 
Hello ,
I am trying to do following in vba

name value
a 1
b 2
c 3

I know the name value , how do I find whats the row number where the
name='a'.

thx
ray




Ron de Bruin

how to find row with a given value in a column
 
Hi

This is a example with a inputbox
Use the commented line if you want to select the cell

Sub Find_First()
Dim FindString As String
Dim Rng As Range
FindString = InputBox("Enter a Search value")
If Trim(FindString) < "" Then
Set Rng = Range("A:A").Find(What:=FindString, _
After:=Range("A" & Rows.Count), _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
'If Not Rng Is Nothing Then Application.Goto Rng, True
If Not Rng Is Nothing Then MsgBox Rng.Row
End If
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"rtos" wrote in message ...
Hello ,
I am trying to do following in vba

name value
a 1
b 2
c 3

I know the name value , how do I find whats the row number where the
name='a'.

thx
ray






Don Guillett[_4_]

how to find row with a given value in a column
 
one way
sub findrow()
msgbox columns(1).find("a").row
end sub

--
Don Guillett
SalesAid Software

"rtos" wrote in message
...
Hello ,
I am trying to do following in vba

name value
a 1
b 2
c 3

I know the name value , how do I find whats the row number where the
name='a'.

thx
ray







All times are GMT +1. The time now is 07:38 PM.

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