Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why does my recorded find/replace macro not work when I replay? 1

Status
Not open for further replies.

nefistopoleez

Programmer
Jun 18, 2007
3
US
Hi,

This is my first thread, I'm a new guy...go easy on me!

I recorded a macro: pressed record, did a find and replace and stopped it. Now I run the same macro I just recorded and I get an error: "Compile error, named argument not found" and in the code editor it highlights "Activate:=True".

Here's the exact recorded code:

Sub Macro1()
Cells.Find What:="tweak colors", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, Activate:=True
ActiveCell.Replace What:="tweak colors", Replacement:="tweak colors more", _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False
Cells.Find What:="tweak colors", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, Activate:=True
End Sub


*** If I take out the Activate:=True then it runs without any errors, but it doesn't work...

Thanks!
ps - I'm using excel:mac v. x - perhaps that is my problem
 
Try this instead:
Cells.Find(What:="tweak colors", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks! It worked!

Really appreciate it...getting things to work is so exciting for new guys.
 
nefistopoleez,

Tip: Use the [COLOR=red yellow]Star[/color] link at the bottom of the post when you want to thank someone. It not only counts towards Tipmaster of the Week, it also helps others know that there is valuable information in the post that they might find useful.

"A committee is a life form with six or more legs and no brain." -- L. Long
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top