How to apply the variable and functions (indirect, address) to this formula?

vcheung

New Member
Joined
Jan 7, 2021
Messages
9
Office Version
  1. 2016
Platform
  1. Windows
I am using this formula "=SUMPRODUCT(('wk52'!$D$6:$AD$6=Summary!$K11)*('wk52'!$D$78:$AD$78))" in my Excel spreadsheet but I would like to set the worksheet name "wk52" as variable, please advise how to convert this formula by using the variable and the functions (indirect, address).

Thanks.
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
I suppose your sheet name is in B6 then:

Excel Formula:
=SUMPRODUCT((INDIRECT(B6&!$D$6:$AD$6)=Summary!$K11)*((INDIRECT(B6&!$D$78:$AD$78))
 
Upvote 0
I suppose your sheet name is in B6 then:

Excel Formula:
=SUMPRODUCT((INDIRECT(B6&!$D$6:$AD$6)=Summary!$K11)*((INDIRECT(B6&!$D$78:$AD$78))
No, the sheet name is "wk52" currently and a new worksheet name "wk53" in following week, so I want to convert my given formula by setting the worksheet name as variable that the output can be changed by changing the variable in cover sheet. As I know it needs to use the function "indirect" and "address" to create the range with the variable but I have no idea how to make it. please help.
 
Upvote 0
Sorry previous formula not working Use this:
Excel Formula:
=SUMPRODUCT((INDIRECT("'"&B6&"'!"&"$D$6:$AD$6")=Summary!$K11)*((INDIRECT("'"&B6&"'!"&"$D$78:$AD$78"))))
Change B6 to your Cell address of Sheet name.
 
Upvote 0
Solution
AND if you want to Use active sheet name at formula.
1. You can delete sheet name at formula easily then formula is:
Excel Formula:
=SUMPRODUCT($D$6:$AD$6=Summary!$K11)*($D$78:$AD$78))
or if you what Extract sheet name Separately:
Excel Formula:
=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,255)
AND combine it with your formula:
Excel Formula:
=SUMPRODUCT((INDIRECT("'"&MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,255)&"'!"&"$D$6:$AD$6")=Summary!$K11)*((INDIRECT("'"&MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,255)&"'!"&"$D$78:$AD$78"))))
 
Upvote 0

Forum statistics

Threads
1,214,426
Messages
6,119,414
Members
448,895
Latest member
omarahmed1

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