Create a Macro to update File and Worksheet References in Formulas

  • Thread starter Thread starter Padrager
  • Start date Start date
P

Padrager

I need to create a macro that will update the file name and worksheet (tab)
references for all formulas within a range. I already have set up form drop
down boxes for the users to select the file and worksheet reference. I need
the VBA coding that will capture the users inputs and complete a find/replace
on all of the formulas for file name/worksheet. Would anyone provide the code
or point me in the direction of where this has been discussed previously?
Much Thanks!!!!
 
Sub replaceformula()

OldFile = "OldFile"
NewFile = "NewFile"
OldSheetName = "OldSheet"
NewSheetName = "NewSheet"

Set ReplaceRange = Range("A1:G7")
ReplaceRange.Replace What:=OldFile, _
Replacement:=NewFile, _
SearchOrder:=xlByColumns, _
MatchCase:=True
ReplaceRange.Replace What:=OldSheetName, _
Replacement:=NewSheetName, _
SearchOrder:=xlByColumns, _
MatchCase:=True

End Sub
 

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