RockandGrohl
Well-known Member
- Joined
- Aug 1, 2018
- Messages
- 810
- Office Version
- 365
- Platform
- Windows
Hello
I'm taking a workbook with many sheets in, and using VBA to drag copy these worksheets into a new template workbook. I'm then copying the formulas from a summary sheet into my new template workbook, and of course it references the sheets on the old workbook. Annoyingly, the formula is like this:
Sheet 1 Range B10 + Sheet 2 Range B10 + Sheet 3 Range B10 etc
What I'd like to do is a find and replace on the summary sheet in the template, after all the tabs have been copied over, and replace the reference to the sheets on the old workbook, with the sheets on the new workbook. Is this possible? ChatGPT seems to think a find and replace would do the trick but of course that's not the way it works in practice. Thanks.
EDIT: Ah nevermind, sorted it, had some stuff in the wrong place. In case anyone wants to know how..
I'm taking a workbook with many sheets in, and using VBA to drag copy these worksheets into a new template workbook. I'm then copying the formulas from a summary sheet into my new template workbook, and of course it references the sheets on the old workbook. Annoyingly, the formula is like this:
Sheet 1 Range B10 + Sheet 2 Range B10 + Sheet 3 Range B10 etc
What I'd like to do is a find and replace on the summary sheet in the template, after all the tabs have been copied over, and replace the reference to the sheets on the old workbook, with the sheets on the new workbook. Is this possible? ChatGPT seems to think a find and replace would do the trick but of course that's not the way it works in practice. Thanks.
EDIT: Ah nevermind, sorted it, had some stuff in the wrong place. In case anyone wants to know how..
VBA Code:
replacestring = "[" & newbook.Name & "]"
ct.Range("B1:E38").Replace What:=replacestring, Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2