ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VB Find (https://www.excelbanter.com/excel-programming/283474-vbulletin-find.html)

Michael Kintner

VB Find
 
How can I do a find within a range in VB and return the cell location of
that find?

Thanks in advance for your help?

Mike



Tom

VB Find
 
the following example returns all cells with the required value.

Tom


Sub Find()
Dim r As Range
Dim strFind As String
Dim strAddress As String

strFind = "Hello"

With ActiveSheet

Set r = .Cells.Find(strFind)
If Not r Is Nothing Then
strAddress = r.Address
Do
MsgBox r.Address
Set r = Cells.FindNext(r)
Loop While Not r Is Nothing And r.Address < strAddress
Else
MsgBox "Not found"
End If
End With
End Sub



"Michael Kintner" schrieb im Newsbeitrag
...
How can I do a find within a range in VB and return the cell location of
that find?

Thanks in advance for your help?

Mike





Tom Ogilvy

VB Find
 
see the example code in Excel VBA help on the Find method.

or turn on the macro recorder, then do Edit=Find

--
Regards,
Tom Ogilvy

"Michael Kintner" wrote in message
...
How can I do a find within a range in VB and return the cell location of
that find?

Thanks in advance for your help?

Mike






All times are GMT +1. The time now is 03:00 PM.

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