VBA to find and replace based on columns

mountainman88

Board Regular
Joined
Jun 22, 2019
Messages
109
Office Version
  1. 2016
Platform
  1. Windows
I have a 'consolidation' tab with a bunch of 3D sum formulas which refernce 'tab1' and 'tab2' ie the formula in any cell looks like: =sum(tab1:tab2![cell reference])

I want to use the 'consolidation' tab as a basis to create other tabs with 3D sums that refernce difference sheets based on a table on the 'table' tab

New tab nametab1tab2
USAarizonaohio
Europeuksingapore
HQBalance SheetTopside

Can i get some VBA that goes down the table (lets say the table starts in cell A1 of the 'tables' tab) and duplicates the 'consolidation' tab, renames it 'new tab name', then performs a find and replace to replace tab1 and tab2 text with the corresponding items in the table.

eg. for the first line 'Consolidation' would be duplicated, renamed 'USA', then tab1 text in the 3D sum would be replaced with Arizona and the tab 2 text would be replaced with Ohio.

Continuing down the list until all 3D sum tabs in the list are created. The list of tabs can be variable in length.

Thanks!
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
I guess many find it is hard to understand hat you were trying to achieve here including me :)
 
Upvote 0
Read it one more time! Its pretty clearly and logically laid out. Find and replace text on a function =sum(tab1:tab2![cell reference]) mentioned in the first line. There are multiple tabs to copy that are each named what's in column headed 'new tab name'.

The start and end of each 3Dsum is renamed the contents of tab 1 and tab 2 eg:

'consolidation' tab is copied, renamed 'USA', after the find and replace for tab1 and tab2 text, each 3DSUM formula on it will end up looking like =sum('arizona':'ohio'![cell reference])
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,853
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top