ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Find method (https://www.excelbanter.com/excel-programming/327558-find-method.html)

nk

Find method
 
Is this posible to get a row number(when the value 2 was find) with a
Find metod in code:
With Worksheets(1).Range("a1:a500")
Set c = .Find(2, lookin:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Value = 5
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With

Thanks'

Bob Phillips[_6_]

Find method
 
Yes, it will be c.Row

--

HTH

RP
(remove nothere from the email address if mailing direct)


"nk" wrote in message
m...
Is this posible to get a row number(when the value 2 was find) with a
Find metod in code:
With Worksheets(1).Range("a1:a500")
Set c = .Find(2, lookin:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Value = 5
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With

Thanks'




Don Guillett[_4_]

Find method
 
If you only need to find the first instance then this will work.

Sub find2()
MsgBox Columns(1).Find(2, lookat:=xlWhole).Row
End Sub


--
Don Guillett
SalesAid Software

"nk" wrote in message
m...
Is this posible to get a row number(when the value 2 was find) with a
Find metod in code:
With Worksheets(1).Range("a1:a500")
Set c = .Find(2, lookin:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Value = 5
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With

Thanks'





All times are GMT +1. The time now is 01:18 AM.

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