View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Variable in a Search and Replace macro

Do you mean something like

Sub FindIt(myVar)
FOR X= 1 TO 80
Selection.Replace What:="min1", Replacement:=myVar, etc etc....
NEXT X
End Sub

which you would usitlise like so


FindIt "min27"
FindIt "minX"

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Sandy" wrote in message
...
I have a formula in many worksheets that needs to be modified.

I have a macro that goes to each worksheet but I would like to use a
variable in the text to be replaced so I dont have to update the macro for
each sheet.

I would like to something like;

FOR X= 1 TO 80

Selection.Replace What:="min1", Replacement:="min27", etc etc....


NEXT X

Where the replacement string becomes

Replacement:="minX"

and increments for each x

Is this possible?

thanks
sandy