Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I need to add the values in columns C2 to AL2 with the number of columns to
be included in the SUM depending on a variable that is entered by the user. Cells C2 to AL2 contain the values and the row below C3 to AL3 contain the formula to add the specified number of columns in the row above. For example, if the user enters the value 3 in cell A1 then the formula should add the 3 columns preceeding the cell with the formula. If the formula is in cell G3, then the cells E2:G2 should be added. If the forumla is in cell H3 then the cells F2:G2 should be added and so on. I need something like this, if this formula were in cell G3: Sum(G2-A1:G2). I know this is not the correct syntax but hopefully it shows what I am trying to do. Thank you in advance for your help. |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi,
Try this in C3: =SUM(INDIRECT(CHAR(MAX(65,65+COLUMN()-$A$1))&2&":"&CHAR(64+COLUMN())&2)) copy across to AL3 HTH Jean-Guy "rt10516" wrote: I need to add the values in columns C2 to AL2 with the number of columns to be included in the SUM depending on a variable that is entered by the user. Cells C2 to AL2 contain the values and the row below C3 to AL3 contain the formula to add the specified number of columns in the row above. For example, if the user enters the value 3 in cell A1 then the formula should add the 3 columns preceeding the cell with the formula. If the formula is in cell G3, then the cells E2:G2 should be added. If the forumla is in cell H3 then the cells F2:G2 should be added and so on. I need something like this, if this formula were in cell G3: Sum(G2-A1:G2). I know this is not the correct syntax but hopefully it shows what I am trying to do. Thank you in advance for your help. |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
That worked perfectly. Thank You!!
"pinmaster" wrote: Hi, Try this in C3: =SUM(INDIRECT(CHAR(MAX(65,65+COLUMN()-$A$1))&2&":"&CHAR(64+COLUMN())&2)) copy across to AL3 HTH Jean-Guy "rt10516" wrote: I need to add the values in columns C2 to AL2 with the number of columns to be included in the SUM depending on a variable that is entered by the user. Cells C2 to AL2 contain the values and the row below C3 to AL3 contain the formula to add the specified number of columns in the row above. For example, if the user enters the value 3 in cell A1 then the formula should add the 3 columns preceeding the cell with the formula. If the formula is in cell G3, then the cells E2:G2 should be added. If the forumla is in cell H3 then the cells F2:G2 should be added and so on. I need something like this, if this formula were in cell G3: Sum(G2-A1:G2). I know this is not the correct syntax but hopefully it shows what I am trying to do. Thank you in advance for your help. |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
This formula works up to column Z, however, once I get into the columns AA,
AB, etc I get a #REF! error. I think the CHAR function is returning a symbol rather than a letter from Char(91) and on. How can I get the formula to work for columns beyond Z? Thanks "pinmaster" wrote: Hi, Try this in C3: =SUM(INDIRECT(CHAR(MAX(65,65+COLUMN()-$A$1))&2&":"&CHAR(64+COLUMN())&2)) copy across to AL3 HTH Jean-Guy "rt10516" wrote: I need to add the values in columns C2 to AL2 with the number of columns to be included in the SUM depending on a variable that is entered by the user. Cells C2 to AL2 contain the values and the row below C3 to AL3 contain the formula to add the specified number of columns in the row above. For example, if the user enters the value 3 in cell A1 then the formula should add the 3 columns preceeding the cell with the formula. If the formula is in cell G3, then the cells E2:G2 should be added. If the forumla is in cell H3 then the cells F2:G2 should be added and so on. I need something like this, if this formula were in cell G3: Sum(G2-A1:G2). I know this is not the correct syntax but hopefully it shows what I am trying to do. Thank you in advance for your help. |
#5
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi,
Sorry for being late, I did not see your last post until now! This should work better: =SUM(INDIRECT(ADDRESS(2,MAX(1,COLUMN()-$A$1))&":"&ADDRESS(2,COLUMN()))) Cheers! Jean-Guy "rt10516" wrote: This formula works up to column Z, however, once I get into the columns AA, AB, etc I get a #REF! error. I think the CHAR function is returning a symbol rather than a letter from Char(91) and on. How can I get the formula to work for columns beyond Z? Thanks "pinmaster" wrote: Hi, Try this in C3: =SUM(INDIRECT(CHAR(MAX(65,65+COLUMN()-$A$1))&2&":"&CHAR(64+COLUMN())&2)) copy across to AL3 HTH Jean-Guy "rt10516" wrote: I need to add the values in columns C2 to AL2 with the number of columns to be included in the SUM depending on a variable that is entered by the user. Cells C2 to AL2 contain the values and the row below C3 to AL3 contain the formula to add the specified number of columns in the row above. For example, if the user enters the value 3 in cell A1 then the formula should add the 3 columns preceeding the cell with the formula. If the formula is in cell G3, then the cells E2:G2 should be added. If the forumla is in cell H3 then the cells F2:G2 should be added and so on. I need something like this, if this formula were in cell G3: Sum(G2-A1:G2). I know this is not the correct syntax but hopefully it shows what I am trying to do. Thank you in advance for your help. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Calculating values in two columns based on a variable | Excel Discussion (Misc queries) | |||
Macro - Using a variable number of columns in a Range | Excel Discussion (Misc queries) | |||
Sum cells based on a row variable and seperate column variable | Excel Worksheet Functions | |||
adding variable number of columns | Excel Worksheet Functions | |||
Chart based on variable number of columns | Charts and Charting in Excel |