What does this mean?

wildturkey

Board Regular
Joined
Feb 21, 2006
Messages
189
Office Version
  1. 365
Platform
  1. Windows
HI, I've been using this formula for some time and I can just about fudge the way it works.

=SUMPRODUCT(SUMIF(INDIRECT("'"&Courses&"'!b:b"),$B4,INDIRECT("'"&Courses&"'!"&SUBSTITUTE(SUBSTITUTE(REPT(ADDRESS(1,COLUMNS($A:G),4),2),1,":",1),1,""))))

I understand its looking at the named range 'Courses' and picking up individual sheet names there, and if they exist adding up their values based on cell $B4, but could someone please explain the SUBSTITUTE(SUBSTITUTE(REPT(ADDRESS(1,COLUMNS($A:G),4),2),1,":",1),1,"")))) element, especially how the $A:G part works and whether the following digits have any impact on the column that gets summed - or is that purely down to the £A: G element?

Many thanks
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Im struggling to see the point of it to be honest. Just produces G:G. Not sure why you wouldnt just type G:G.
 
Upvote 0
Sorry i wasnt looking at the correct context. I just looked at the formula rather than in conjunction with the indirect.
 
Upvote 0
So breaking down the formula:

=SUBSTITUTE(SUBSTITUTE(REPT(ADDRESS(1,COLUMNS($A:G),4),2),1,":",1),1,"")

First calculate the COLUMNS($A:G) which produces 7. Formula now is:

=SUBSTITUTE(SUBSTITUTE(REPT(ADDRESS(1,7,4),2),1,":",1),1,"")

Then the ADDRESS part, ADDRESS(1,7,4), produces G1. Our formula now is:

=SUBSTITUTE(SUBSTITUTE(REPT("G1",2),1,":",1),1,"")

Now REPT("G1",2) produces G1G1. Formula now is:

=SUBSTITUTE(SUBSTITUTE("G1G1",1,":",1),1,"")

Now the 2nd SUBSTITUTE you see above is SUBSTITUTE("G1G1",1,":",1). This produces G:G1. We now have:

=SUBSTITUTE("G:G1",1,"")

Which resolves to G:G.
 
Upvote 0
Many thanks, will start trying to work that through and get it clear in my head, but that is excellent thank you!!
 
Upvote 0

Forum statistics

Threads
1,213,490
Messages
6,113,956
Members
448,535
Latest member
alrossman

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