Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Variable reference to add cells
I want to use a variable to add a number of cell values together:
in the example below cell 'e3' needs to be the sum of cells a1:a2 less the sum of cells a4:e5 but I need to use the value of cell 'a5' to 'go back' 4 columns so that I can vary the number of columns to count back by changing the value of a5. a b c d e 1 10 2 20 3 4 2 2 4 2 2 5 4 Thanks |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Variable reference to add cells
If I understand your question correctly this should be close...
=SUM(A1:A2)-SUM(A4:INDEX(4:4, 1, A5+1)) -- HTH... Jim Thomlinson "Nick Savage" wrote: I want to use a variable to add a number of cell values together: in the example below cell 'e3' needs to be the sum of cells a1:a2 less the sum of cells a4:e5 but I need to use the value of cell 'a5' to 'go back' 4 columns so that I can vary the number of columns to count back by changing the value of a5. a b c d e 1 10 2 20 3 4 2 2 4 2 2 5 4 Thanks |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Variable reference to add cells
Thanks Jim, I think I need to explain better:
I need a1:a2 and a4:e4 to be referenced from e3, using the value in a5 (the rows will always be 1 & 2 and 4 but the columns need to be dependent on the value of a5 so if a5 was 4 the answer would be 20 (a1:a2) - (a4:e4) and if a5 was 3 the answer would be 12 (b1:b2) - (b4:e4) key is to change a5 and have different answers without changing formula a b c d e 1 10 5 2 20 15 3 4 2 2 2 2 2 5 4 Nick "Jim Thomlinson" wrote: If I understand your question correctly this should be close... =SUM(A1:A2)-SUM(A4:INDEX(4:4, 1, A5+1)) -- HTH... Jim Thomlinson "Nick Savage" wrote: I want to use a variable to add a number of cell values together: in the example below cell 'e3' needs to be the sum of cells a1:a2 less the sum of cells a4:e5 but I need to use the value of cell 'a5' to 'go back' 4 columns so that I can vary the number of columns to count back by changing the value of a5. a b c d e 1 10 5 2 20 15 3 4 2 2 2 2 2 5 4 Thanks |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
Variable reference to add cells
=INDEX(A1:E1,1,5-A5)+INDEX(A2:E2,1,5-A5)-SUM(INDEX(A4:E4,1,5-A5):E4)
-- HTH... Jim Thomlinson "Nick Savage" wrote: Thanks Jim, I think I need to explain better: I need a1:a2 and a4:e4 to be referenced from e3, using the value in a5 (the rows will always be 1 & 2 and 4 but the columns need to be dependent on the value of a5 so if a5 was 4 the answer would be 20 (a1:a2) - (a4:e4) and if a5 was 3 the answer would be 12 (b1:b2) - (b4:e4) key is to change a5 and have different answers without changing formula a b c d e 1 10 5 2 20 15 3 4 2 2 2 2 2 5 4 Nick "Jim Thomlinson" wrote: If I understand your question correctly this should be close... =SUM(A1:A2)-SUM(A4:INDEX(4:4, 1, A5+1)) -- HTH... Jim Thomlinson "Nick Savage" wrote: I want to use a variable to add a number of cell values together: in the example below cell 'e3' needs to be the sum of cells a1:a2 less the sum of cells a4:e5 but I need to use the value of cell 'a5' to 'go back' 4 columns so that I can vary the number of columns to count back by changing the value of a5. a b c d e 1 10 5 2 20 15 3 4 2 2 2 2 2 5 4 Thanks |
#5
Posted to microsoft.public.excel.misc
|
|||
|
|||
Variable reference to add cells
Wow!!
Cheers Jim, a great help -- Nick "Jim Thomlinson" wrote: =INDEX(A1:E1,1,5-A5)+INDEX(A2:E2,1,5-A5)-SUM(INDEX(A4:E4,1,5-A5):E4) -- HTH... Jim Thomlinson "Nick Savage" wrote: Thanks Jim, I think I need to explain better: I need a1:a2 and a4:e4 to be referenced from e3, using the value in a5 (the rows will always be 1 & 2 and 4 but the columns need to be dependent on the value of a5 so if a5 was 4 the answer would be 20 (a1:a2) - (a4:e4) and if a5 was 3 the answer would be 12 (b1:b2) - (b4:e4) key is to change a5 and have different answers without changing formula a b c d e 1 10 5 2 20 15 3 4 2 2 2 2 2 5 4 Nick "Jim Thomlinson" wrote: If I understand your question correctly this should be close... =SUM(A1:A2)-SUM(A4:INDEX(4:4, 1, A5+1)) -- HTH... Jim Thomlinson "Nick Savage" wrote: I want to use a variable to add a number of cell values together: in the example below cell 'e3' needs to be the sum of cells a1:a2 less the sum of cells a4:e5 but I need to use the value of cell 'a5' to 'go back' 4 columns so that I can vary the number of columns to count back by changing the value of a5. a b c d e 1 10 5 2 20 15 3 4 2 2 2 2 2 5 4 Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Using variable for cell reference | Excel Discussion (Misc queries) | |||
How to reference variable range? | Excel Discussion (Misc queries) | |||
Sum cells based on a row variable and seperate column variable | Excel Worksheet Functions | |||
How to use variable in reference | Excel Worksheet Functions | |||
Problem with =sum(offset(cell reference,w,x,y,z). I want cell reference to be variable | Excel Worksheet Functions |