Change Formula Name

  • Thread starter Thread starter ronbo
  • Start date Start date
R

ronbo

I am looking for a macro that can update formulas with
the current month. The simplest use would be to update a
formula that last month referenced last month to a
formula that now reference the current month. Example:
Last Month the formula = [REPORT JUN 04.xls]SHEET1'!A1.
This month I want the formula updated to = [REPORT JUL
04.xls]SHEET1'!A1.

I am trying to use a simple "Find & Replace"
and/or "Links Change" plus code that Tom Ogilvy wrote.
But I can 't get either to work. In the "Find & Replace"
I am using variations (for Date format "mmm yy":

Cells.Select
Selection.Replace What:=Today()-1), Replacement:=today
(),LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False

And it creates a syntax error. With Links Change I
get "Argument Not Optional" error on .ChangeLink Name:=

Thanks to all that have helped and any additional help
will be very much appreciated.
 
from help the format is:

ActiveWorkbook.ChangeLink "c:\excel\book1.xls", _
"c:\excel\book2.xls", xlExcelLinks


so for you:

Dim sNew as String, sOld as String

sNew = "c:\myfolder\REPORT " & format(DateSerial( _
year(date),Month(date),1),"mmm yy") & ".xls"
sOld = "c:\myfolder\REPORT " & format(DateSerial( _
year(date),Month(date)-1,1),"mmm yy") & ".xls"

ActiveWorkbook.ChangeLink sOld, sNew, xlExcelLinks
 

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

Back
Top