help me understand this function

litoria

New Member
Joined
Oct 15, 2009
Messages
4
I was given an excel sheet today with this function:
=SUM(INDIRECT(ADDRESS(ROW(C26),COLUMN(C26)) & ":" & ADDRESS(ROW(C26),COLUMN(C26)+C9,4)))

Can someone help me to understand how this works? I have never seen the INDIRECT or ADDRESS functions before. Thanks!
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
I was given an excel sheet today with this function:
=SUM(INDIRECT(ADDRESS(ROW(C26),COLUMN(C26)) & ":" & ADDRESS(ROW(C26),COLUMN(C26)+C9,4)))
Can someone help me to understand how this works? I have never seen the INDIRECT or ADDRESS functions before. Thanks!
i will guide you step by step to understand.
Example: You have array of number from C26:G26, with value of 5,2,1,2,3
At D9, you want to get sum with above formular
At C9 is adjust value.
How it run?
If C9=0, D9 = sum(C26:C26) = 5
If C9=1, D9 = sum(C26:D26) = 7
If C9=2, D9 = sum(C26:E26) = 8
If C9=3, D9 = sum(C26:F26) = 10
mean the range will expanse 1,2,3 collumn to the right, depend on C9.
Explan formular:
ADDRESS(ROW(C26),COLUMN(C26)) returns C26 (in text format)
ADDRESS(ROW(C26),COLUMN(C26)+C9,4), if C9=1, return D26 (in text format)
INDIRECT(ADDRESS(ROW(C26),COLUMN(C26)) & ":" & ADDRESS(ROW(C26),COLUMN(C26)+C9,4)) return range C26:D26 if C9=1 (in address format)

Below formular is equal:
=SUM(OFFSET($C$26,,,,C9+1))

Hope it is clear for you.
 
Upvote 0
This is very helpful. What does the 4 at the end of the formula do?
Construction:
ADDRESS(row_num,col_num,abs_num,a1,sheet_text)
Example:
=ADDRESS(1,2) ===> $B$1
=ADDRESS(1,2,2) ===> B$1
=ADDRESS(1,2,3) ===> $B1
=ADDRESS(1,2,4) ===> B1
=ADDRESS(1,2,4,TRUE) ===> B1
=ADDRESS(1,2,4,FALSE) ===> R[1]C[2]
=ADDRESS(1,2,4,TRUE,"sheet1") ===> sheet1!B1
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,719
Members
452,939
Latest member
WCrawford

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