colinheslop1984

Board Regular
Joined
Oct 14, 2016
Messages
129
Office Version
  1. 2016
I have 5 documents with 52 tabs, one per week.

I have another sheet where I want to consolidate the data.

Because the sheets represent week numbers I want to throw in a criteria referencing the sheet name so that I can just copy and paste the formula into the weekly tabs of my master sheet rather than having to retype them all.

For example if I have sheets 1:52 on all documents including master and I use

=INDEX('[LE2.xlsx]22'!$D$5:$D$6,1,1)

this will sum exactly what I need but only for this particular worksheet so it means I would have to change 22! to 23! to 24! for every calculation I need to make which would take too long.

What if I have the worksheet name '22' or '23' etc in cell I1, how can I use this to capture the data I need.

In other words, I want to search all worksheets for [LE2] for the one which matches the name in I1 then sum cell D5 from that tab. How do I do it?

I was thinking indirect but then I'm not sure how to write this up when its referencing an external source
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Anyone??

I have 5 documents with 52 tabs, one per week.

I have another sheet where I want to consolidate the data.

Because the sheets represent week numbers I want to throw in a criteria referencing the sheet name so that I can just copy and paste the formula into the weekly tabs of my master sheet rather than having to retype them all.

For example if I have sheets 1:52 on all documents including master and I use

=INDEX('[LE2.xlsx]22'!$D$5:$D$6,1,1)

this will sum exactly what I need but only for this particular worksheet so it means I would have to change 22! to 23! to 24! for every calculation I need to make which would take too long.

What if I have the worksheet name '22' or '23' etc in cell I1, how can I use this to capture the data I need.

In other words, I want to search all worksheets for [LE2] for the one which matches the name in I1 then sum cell D5 from that tab. How do I do it?

I was thinking indirect but then I'm not sure how to write this up when its referencing an external source
 
Upvote 0
.
Code:
Option Explicit


Sub foo()
Dim ws As Worksheet


For Each ws In ActiveWorkbook.Worksheets
    ws.Range("D7").Formula = "=(A1)"    '<-- your formula here
Next


End Sub
 
Upvote 0
.
The macro I posted should be inserted into a regular Module. You activate it by a command button placed on your worksheet.

Where you see "=(A1)" ... replace that portion with your formula ... "=INDEX('[LE2.xlsx]22'!$D$5:$D$6,1,1)" . Be certain to place your formula inside the quotes.

Because I don't have your workbook/s here to test with .... I am not certain if your formula will function as desired or if you will need to edit your formula.
 
Upvote 0

Forum statistics

Threads
1,214,599
Messages
6,120,453
Members
448,967
Latest member
grijken

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