Search macro

  • Thread starter Thread starter carg1
  • Start date Start date
C

carg1

I'm trying to make a macro that copies the contents of a cell, pastes i
into the find dialog box, then searches for whatever was pasted.
started it with a recording then tweaked it. Unfortunately, I came t
realize I'm not quite sure how to tell it to paste the copied data int
find. Any ideas? Here's my code:

Dim Term

Term = Selection.Copy
Cells.Find(What:="Term", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext
_
MatchCase:=False).Activat
 
try
Cells.Find(What:=selection, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
 
Assign to a variable then call it - no copy paste required
and u still have the flexability to change cells after the
assignment.

Dim z As String
Range("B3").Select
z = ActiveCell.Value
Cells.Find(What:=z, After:=ActiveCell,
LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, MatchCase:= _
False).Activate
 
carg

Dim Term As String
Term = Selection.Value
Cells.Find(What:=Term, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate

Gord Dibben Excel MVP
 

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