using variables with Find

  • Thread starter Thread starter Arle
  • Start date Start date
A

Arle

I've written a macro that filters records from a master list of names
and addresses based on specific criteria (on the invitation list for
specific fundraisers or to be approached regarding donating to
specific campaigns), and then those names and addresses are copied
onto a new page for easier viewing.

As it stands now, I have a note at the top of the page stating that
edits to addresses need to be made on the master page.

I tried to record a macro that would take a name from the condensed
list and then find it on the master list, but when I use the macro
recorder, it records the text of the name ("persons name") I used to
record the macro. I'd like it to choose the text from whatever cell
the user has chosen before running the macro, OR, I'd like a message
box to appear asking for the text to find.

Can someone give me some guidance?.. Thanks. My Excel skills are
pretty good, but I haven't used VBA in a while and don't quite have a
handle on all the codes.

Arletta
 
Sub test()
Dim personToFind As String

personToFind = InputBox("Enter person to find")
Cells.Find(What:=personToFind, After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
End Sub
 
Thank you so much! I needed to add a reference to the other sheet just
in case they didn't click in the name field to begin with.

personToFind = InputBox("Enter name exactly as it appears in
column A")
Sheets("complete list").Select
Range("A1").Select
 

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