ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Formula to sum columns based on # in Cell A1 (https://www.excelbanter.com/excel-discussion-misc-queries/151442-formula-sum-columns-based-cell-a1.html)

Karin

Formula to sum columns based on # in Cell A1
 
I have columns 5-16 (E:P) filled with monthly data.
Column 5 (E) contains May, column 6 (F) June, etc.
I
n Cell A1 I have the current month (7 for July, 8 for Aug, etc.). Cell A1
has the formula =now() in it and is formatted as "m" so it only shows 7 for
July, which corresponds with column 7 (G).

I want to sum cells E5 through ?5 based on the number in cell A1.
For July the sum would be E5:G5, for August it would be E5:H5, etc.)
What fomula would I use to create the sum based on the data in cell A1?
TIA!

Karin

Formula to sum columns based on # in Cell A1
 
I made a slight change (Cell A1 is now a hard coded number, not a date
formatted to look like a number).

"Karin" wrote:

I have columns 5-16 (E:P) filled with monthly data.
Column 5 (E) contains May, column 6 (F) June, etc.
In Cell A1 I have the current month (7 for July, 8 for Aug, etc.).

I want to sum cells E5 through ?5 based on the number in cell A1.
For July the sum would be E5:G5, for August it would be E5:H5, etc.)
What fomula would I use to create the sum based on the data in cell A1?
TIA!


Jim Rech

Formula to sum columns based on # in Cell A1
 
=SUM(OFFSET(E5,0,0,1,A1-4))

--
Jim
"Karin" wrote in message
...
|I made a slight change (Cell A1 is now a hard coded number, not a date
| formatted to look like a number).
|
| "Karin" wrote:
|
| I have columns 5-16 (E:P) filled with monthly data.
| Column 5 (E) contains May, column 6 (F) June, etc.
| In Cell A1 I have the current month (7 for July, 8 for Aug, etc.).
|
| I want to sum cells E5 through ?5 based on the number in cell A1.
| For July the sum would be E5:G5, for August it would be E5:H5, etc.)
| What fomula would I use to create the sum based on the data in cell A1?
| TIA!



David Biddulph[_2_]

Formula to sum columns based on # in Cell A1
 
=SUM(E5:OFFSET(E5,0,MOD(MONTH(A1)-5,12)))
--
David Biddulph

"Karin" wrote in message
...
I have columns 5-16 (E:P) filled with monthly data.
Column 5 (E) contains May, column 6 (F) June, etc.
I
n Cell A1 I have the current month (7 for July, 8 for Aug, etc.). Cell A1
has the formula =now() in it and is formatted as "m" so it only shows 7
for
July, which corresponds with column 7 (G).

I want to sum cells E5 through ?5 based on the number in cell A1.
For July the sum would be E5:G5, for August it would be E5:H5, etc.)
What fomula would I use to create the sum based on the data in cell A1?
TIA!




Karin

Formula to sum columns based on # in Cell A1
 
Thank you. Now let's get more complex. Is there anyway to return this
formula in a Vlookup? I'm looking up a name in the range YTD, then I want to
do this formula for the row that the name is in.

"Jim Rech" wrote:

=SUM(OFFSET(E5,0,0,1,A1-4))

--
Jim
"Karin" wrote in message
...
|I made a slight change (Cell A1 is now a hard coded number, not a date
| formatted to look like a number).
|
| "Karin" wrote:
|
| I have columns 5-16 (E:P) filled with monthly data.
| Column 5 (E) contains May, column 6 (F) June, etc.
| In Cell A1 I have the current month (7 for July, 8 for Aug, etc.).
|
| I want to sum cells E5 through ?5 based on the number in cell A1.
| For July the sum would be E5:G5, for August it would be E5:H5, etc.)
| What fomula would I use to create the sum based on the data in cell A1?
| TIA!




David Biddulph[_2_]

Formula to sum columns based on # in Cell A1
 
OK for months from 5 to 12, but not for 1 to 4 inclusive, Jim.
You'll need the MOD() function as in my earlier answer before the question
changed.
--
David Biddulph

"Jim Rech" wrote in message
...
=SUM(OFFSET(E5,0,0,1,A1-4))


"Karin" wrote in message
...
|I made a slight change (Cell A1 is now a hard coded number, not a date
| formatted to look like a number).
|
| "Karin" wrote:
|
| I have columns 5-16 (E:P) filled with monthly data.
| Column 5 (E) contains May, column 6 (F) June, etc.
| In Cell A1 I have the current month (7 for July, 8 for Aug, etc.).
|
| I want to sum cells E5 through ?5 based on the number in cell A1.
| For July the sum would be E5:G5, for August it would be E5:H5, etc.)
| What fomula would I use to create the sum based on the data in cell
A1?
| TIA!





Jim Rech

Formula to sum columns based on # in Cell A1
 
Thanks, David, for pointing out that I ignored months past December.

Karen, play with something like this:

=SUM(OFFSET(indirect(vlookup(...)),0,0,1,MOD(A1-4,12)))

Use VLOOKUP to get the name of the range and INDIRECT to make Excel find the
range with that name.

--
Jim
"Karin" wrote in message
...
| Thank you. Now let's get more complex. Is there anyway to return this
| formula in a Vlookup? I'm looking up a name in the range YTD, then I want
to
| do this formula for the row that the name is in.
|
| "Jim Rech" wrote:
|
| =SUM(OFFSET(E5,0,0,1,A1-4))
|
| --
| Jim
| "Karin" wrote in message
| ...
| |I made a slight change (Cell A1 is now a hard coded number, not a date
| | formatted to look like a number).
| |
| | "Karin" wrote:
| |
| | I have columns 5-16 (E:P) filled with monthly data.
| | Column 5 (E) contains May, column 6 (F) June, etc.
| | In Cell A1 I have the current month (7 for July, 8 for Aug, etc.).
| |
| | I want to sum cells E5 through ?5 based on the number in cell A1.
| | For July the sum would be E5:G5, for August it would be E5:H5, etc.)
| | What fomula would I use to create the sum based on the data in cell
A1?
| | TIA!
|
|
|



Karin

Formula to sum columns based on # in Cell A1
 
Actually, months past December are 13, 14, 15, 16 because I am referencing
the Column number that the month falls in. (It just happened that May, which
is the start of our fiscal year, fell in the 5th column.) But it's good to
have a solution for anyone using typical 1-12 numbers.

"David Biddulph" wrote:

OK for months from 5 to 12, but not for 1 to 4 inclusive, Jim.
You'll need the MOD() function as in my earlier answer before the question
changed.
--
David Biddulph

"Jim Rech" wrote in message
...
=SUM(OFFSET(E5,0,0,1,A1-4))


"Karin" wrote in message
...
|I made a slight change (Cell A1 is now a hard coded number, not a date
| formatted to look like a number).
|
| "Karin" wrote:
|
| I have columns 5-16 (E:P) filled with monthly data.
| Column 5 (E) contains May, column 6 (F) June, etc.
| In Cell A1 I have the current month (7 for July, 8 for Aug, etc.).
|
| I want to sum cells E5 through ?5 based on the number in cell A1.
| For July the sum would be E5:G5, for August it would be E5:H5, etc.)
| What fomula would I use to create the sum based on the data in cell
A1?
| TIA!






Karin

Formula to sum columns based on # in Cell A1
 
Jim, Thanks for the formula, but I can't seem to get it to work. I reposted
this question as a new question (Lookup and Calculate Formula) and I'll post
your answer there. (It seemed to need its own question as it went beyond the
scope of my original question.)

"Jim Rech" wrote:

Thanks, David, for pointing out that I ignored months past December.

Karen, play with something like this:

=SUM(OFFSET(indirect(vlookup(...)),0,0,1,MOD(A1-4,12)))

Use VLOOKUP to get the name of the range and INDIRECT to make Excel find the
range with that name.

--
Jim
"Karin" wrote in message
...
| Thank you. Now let's get more complex. Is there anyway to return this
| formula in a Vlookup? I'm looking up a name in the range YTD, then I want
to
| do this formula for the row that the name is in.
|
| "Jim Rech" wrote:
|
| =SUM(OFFSET(E5,0,0,1,A1-4))
|
| --
| Jim
| "Karin" wrote in message
| ...
| |I made a slight change (Cell A1 is now a hard coded number, not a date
| | formatted to look like a number).
| |
| | "Karin" wrote:
| |
| | I have columns 5-16 (E:P) filled with monthly data.
| | Column 5 (E) contains May, column 6 (F) June, etc.
| | In Cell A1 I have the current month (7 for July, 8 for Aug, etc.).
| |
| | I want to sum cells E5 through ?5 based on the number in cell A1.
| | For July the sum would be E5:G5, for August it would be E5:H5, etc.)
| | What fomula would I use to create the sum based on the data in cell
A1?
| | TIA!
|
|
|





All times are GMT +1. The time now is 05:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com