reading address of cell after Selection.find

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using the the following code to find "-" in a spreadsheet;

Selection.Find(What:="-", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate

How can I get the address of the cell selected by the find?
 
Hi Mel
try
Sub foo()
Dim rng As Range
Set rng = Selection.Find(What:="-", After:=ActiveCell,
LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False)
MsgBox rng.Address
End Sub
 
Or simply (subject to word wrap):

Sub foo()
MsgBox Selection.Find(What:="-", After:=ActiveCell,
LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Address
End Sub

Alan Beban
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top