search and return cell address

  • Thread starter Thread starter Fan924
  • Start date Start date
F

Fan924

I need a macro to search a column of 20 cells. When it find the number
I am looking for, I need it to return the cell address it is found in.
Thanks
 
Good time to learn. Turn on the macro recorder>select the
range>EDIT>find>>>>>
clean up the macro. Post back with additional needs.
 
Since you made the effort to do it yourself, you may like this.

Option Explicit
Sub Findnum()
Dim mc As String
Dim myfind As Range
Dim mynum As Long
mc = "a"
mynum = InputBox("Enter number desired")
MsgBox mynum
Set myfind = Columns(mc).Find(What:=mynum, _
After:=Cells(1, mc), LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)
If Not myfind Is Nothing Then Range("a1") = myfind
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(e-mail address removed)
How do I find the address of the cell it is found in?

Thanks, I found what I need
Range("A1").Value = ActiveCell.Address
 

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