Generate a formula across tabs based on a table

mountainman88

Board Regular
Joined
Jun 22, 2019
Messages
109
Office Version
  1. 2016
Platform
  1. Windows
I have a workbook with 3 tabs named Summary1 - Summary3, and 7 tabs named tab1-tab7

I have a table on another tab in the workbook as below

Cons tabs.xlsx
ABC
1Summary1Summary2Summary3
2Tab1Tab3Tab7
3Tab2Tab4
4Tab5
Sheet2


I need VBA that loops through each column and performs the following:

1.Select summary tab named in row 1 of the table, this starts with Summary1 tab
2.for each cell on the Summary1 tab which has the string 'document' in it's cell formula, replace cell's formula with a sum formula based on the other tabs named in the column

Processing the first column in the table:
1. Select Summary1 tab
2. For each cell that contains the text 'document', replace the text/formula with:
a1=tab1!a1+tab2!a1+tab5!a1,
a2=tab1!a2+tab2!a2+tab5!a2, etc etc , and then on for every cell on the Summary1 tab

Next column in the table: Summary2, all cells that contain the text 'document' replaced by the formula:
a1=tab3!a1+tab4!a1,
a2=tab3!a2+tab4!a2,
a3=tab3!a3+tab4!a3, etc, etc

Next column in the table: Summary3, all cells that contain the text 'document' are replaced by the formula:
a1=tab7!a1,
a2=tab7!a2,
a3=tab7!a3, etc, etc

The columns can have up to 25 tabs named in them below the Summary tab name

Thanks
 
Last edited:

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
I have a workbook with 3 tabs named Summary1 - Summary3, and 7 tabs named tab1-tab7

I have a table on another tab in the workbook as below

Cons tabs.xlsx
ABC
1Summary1Summary2Summary3
2Tab1Tab3Tab7
3Tab2Tab4
4Tab5
Sheet2


I need VBA that loops through each column and performs the following:

1.Select summary tab named in row 1 of the table, this starts with Summary1 tab
2.for each cell on the Summary1 tab which has the string 'document' in it's cell formula, replace cell's formula with a sum formula based on the other tabs named in the column

Processing the first column in the table:
1. Select Summary1 tab
2. For each cell that contains the text 'document', replace the text/formula with:
a1=tab1!a1+tab2!a1+tab5!a1,
a2=tab1!a2+tab2!a2+tab5!a2, etc etc , and then on for every cell on the Summary1 tab

Next column in the table: Summary2, all cells that contain the text 'document' replaced by the formula:
a1=tab3!a1+tab4!a1,
a2=tab3!a2+tab4!a2,
a3=tab3!a3+tab4!a3, etc, etc

Next column in the table: Summary3, all cells that contain the text 'document' are replaced by the formula:
a1=tab7!a1,
a2=tab7!a2,
a3=tab7!a3, etc, etc

The columns can have up to 25 tabs named in them below the Summary tab name

Thanks

I should mention the matching of the text 'document' needs to be *document* as there will be other text in the cell
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,331
Members
452,636
Latest member
laura12345

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