Thread: loop for macro
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Steve Steve is offline
external usenet poster
 
Posts: 1,814
Default loop for macro

Howdee all.
I just recorded a macro to strip off the path to a template document, for
some formulas.
The recorded code is:

Sub extractMe()

Cells.Replace What:= _
"C:\Documents and Settings\UserName\Application _
Data\Microsoft\Templates\[TR Claim Book.xltx]" _
, Replacement:="", LookAt:=xlPart, SearchOrder:=xlByRows,
MatchCase:= _
False, SearchFormat:=False, ReplaceFormat:=False

End Sub

I just tried placing it in a for loop, and I cannot get it to work right. I
keep getting a 438 error.

My throughts we


Dim MyCell as range
For each MyCell in ActiveSheet

' "replace" code from above

next


What code do I use for a loop that will just run through the single page-- I
want to remove all of the template pathways that exist-- varies from 2 or 3
up to around 10 instances.

Thank you.