how do I programatically edit formulae in MS Excel?

G

Guest

In MS EXcel 2003, I have a master workbook with 5 feeder workbooks to enable
a city manager to collect monthy returns from 5 area managers. So in Jan '06
I have CityJan06.xls with many links to NJan06.xls, SJan06.xls, NWJan06.xls,
EJan06.xls and NEJan06.xls. When all the Jan feeders are complete, I want to
programatically copy all 6 workbooks into February's locations with Feb's
dates on the sheets (this I can do) and then edit the links in the Feb master
workbook to point to the new Feb feeders(which I haven't figured out yet).
So, one link in the master wkbk might be"=G:\CSSN06\NJan06\NJan06.xls" and in
the February copy I want to change that programatically to
"-G:\CSSN06\NFeb06\NFeb06.xls". At this stage, I'm not bothered about the
year change in Dec. Everything else in the link stays the same except for the
3-character month name
 
B

Bernie Deitrick

You could do something like this: I assumed all your links are on one sheet:

Sub Macro1()

Dim myRep As String
Dim myFind As String

myFind = InputBox("What month string to replace?")
myRep = InputBox("Replace it with?")

Cells.Replace What:=myFind, Replacement:=myRep, LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub

Answer Jan to the first, and Feb to the second....

HTH,
Bernie
MS 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

Top