I got this as a string: "='C:\Users\Jones\Desktop\[test.xlsx]"
And want to replace "REPLACE_" in a workbook.
Like: "REPLACE_Sheet1'!$D$15
This will output a workbook reference: "='C:\Users\Jones\Desktop\[test.xlsx]Sheet1'!$D$15"
Questian: I cant get the search and replace function to work.
Why is it not working you think?
The code works with just text replacement:
Later on I will build the replace part in a loop.
And want to replace "REPLACE_" in a workbook.
Like: "REPLACE_Sheet1'!$D$15
This will output a workbook reference: "='C:\Users\Jones\Desktop\[test.xlsx]Sheet1'!$D$15"
Questian: I cant get the search and replace function to work.
VBA Code:
Dim HERE as string
HERE = "='C:\Users\Jones\Desktop\[test.xlsx]"
Workbooks("template.xlsm").Activate
Sheets("Sheet1").Select
Cells.Select
Selection.Replace what:="'REPLACE_'", Replacement:=HERE, LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
Why is it not working you think?
The code works with just text replacement:
VBA Code:
Dim HERE as string
HERE = "='C:\Users\Jones\Desktop\[test.xlsx]"
Workbooks("template.xlsm").Activate
Sheets("Sheet1").Select
Cells.Select
Selection.Replace what:="'REPLACE_'", Replacement:="JUST TEXT", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
Later on I will build the replace part in a loop.