jellybean1974
New Member
Hi
I have two workbooks A and B
I regularly copy 80 sheets from workbook B into workbook A
Once copied, the formulas in those copied sheets refer to the filename of the original workbook.
I have a macro that can find and replace the filename where it appears in any formula between []
this was working fine until I "upgraded" to Excel 2013. Now the formulas in the copied sheets refer to the whole file path and the filename of the original workbook
Modifying the find and replace macro to remove the path does not work
Manually deleting the file path and file name from the formula works, so why not in a macro. Please help me
Thanks
J
I have two workbooks A and B
I regularly copy 80 sheets from workbook B into workbook A
Once copied, the formulas in those copied sheets refer to the filename of the original workbook.
I have a macro that can find and replace the filename where it appears in any formula between []
Code:
Sub FindReplaceRef()
Dim ws As Worksheet
Application.ScreenUpdating = False
'this selects all the cells in the workbook that contain formulas
Selection.SpecialCells(xlCellTypeFormulas, 23).Select
For Each ws In ActiveWorkbook.Worksheets
'this finds all the references to other sheets and removes them
Selection.Replace What:="[*]", Replacement:="", LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Next ws
Application.ScreenUpdating = True
End Sub
this was working fine until I "upgraded" to Excel 2013. Now the formulas in the copied sheets refer to the whole file path and the filename of the original workbook
Modifying the find and replace macro to remove the path does not work
Code:
Sub FindReplaceRef()
Dim ws As Worksheet
Application.ScreenUpdating = False
'this selects all the cells in the workbook that contain formulas
Selection.SpecialCells(xlCellTypeFormulas, 23).Select
For Each ws In ActiveWorkbook.Worksheets
'this finds all the references to other sheets and removes them
Selection.Replace What:="'[*]'", Replacement:="DocInfo", LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Next ws
Call replace_CopyrightYear
Application.ScreenUpdating = True
End Sub
Manually deleting the file path and file name from the formula works, so why not in a macro. Please help me
Thanks
J