Using a variable in a "repalcement" string

G

Guest

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",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

NEXT X

Where the replacement string becomes

Replacement:="minX"

and increments for each x

Is this possible?

thanks
sandy
 
S

Steve Schapel

Sandy,

The focus of this newsgroup is macros in Access, the database programme,
and these are a very different concept to macros in Excel, which use VBA
code.

Nevertheless, I'll make this suggestion for you to try...

For X= 1 To 80
Selection.Replace What:="min1", Replacement:="min" & X,
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Next X
 

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

Top