mountainman88
Board Regular
- Joined
- Jun 22, 2019
- Messages
- 109
- Office Version
- 2016
- Platform
- Windows
I have 90 identically structured tabs in a workbook each with their own individual tab name, they link to corresponding tabs on other workbooks eg. tab NA in this workbook links to tab NA in the other workbooks, tab EMEA in this workbook links to tab EMEA in the other workbooks etc
When I need to make changes to the structure of the sheets it is impossible to group select all 90 tabs and make the changes. So instead, I edit one tab alone in a new workbook called TOTAL and then use VBA to duplicate it 90 times and rename the 90 tabs. I have all the tabs I need, labeled individually, but the issue is they all link to the TOTAL tabs on the other workbooks instead of their corresponding tab.
Each sheet is a P&L with hundreds of links, I have used the below VBA to take the tab names from a sheet called 'list', and then in each tab perform a Find and Replace on the links by replacing "TOTAL'!" with the tabname, eg. the VBA will get to EMEA in the list, then perform the Find and Replace on the EMEA tab and replace any instance of "TOTAL'!" with "EMEA'!".
Is there any way to make this process quicker? Can the code be optimized more?
Thanks
When I need to make changes to the structure of the sheets it is impossible to group select all 90 tabs and make the changes. So instead, I edit one tab alone in a new workbook called TOTAL and then use VBA to duplicate it 90 times and rename the 90 tabs. I have all the tabs I need, labeled individually, but the issue is they all link to the TOTAL tabs on the other workbooks instead of their corresponding tab.
Each sheet is a P&L with hundreds of links, I have used the below VBA to take the tab names from a sheet called 'list', and then in each tab perform a Find and Replace on the links by replacing "TOTAL'!" with the tabname, eg. the VBA will get to EMEA in the list, then perform the Find and Replace on the EMEA tab and replace any instance of "TOTAL'!" with "EMEA'!".
Is there any way to make this process quicker? Can the code be optimized more?
VBA Code:
Sub FindReplaceAll()
Dim ws1 As Worksheet, ws2 As Worksheet, c As Range
Dim fnd As Variant
Dim rplc As Variant
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
fnd = "TOTAL'!"
Set ws1 = Sheets("list")
RowCount = ws1.Range("a1", Range("a2").End(xlDown)).Count
For Each c In ws1.Range("a1", "a" & RowCount)
'Store a specific sheet to a variable
Set ws2 = Sheets(c.Value)
rplc = ws2.Name & "'!"
'Perform the Find/Replace All
ws2.Cells.Replace what:=fnd, Replacement:=rplc, _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, _
SearchFormat:=False, ReplaceFormat:=False
Next c
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
Thanks