First Nth Column Sums

peter8848

Board Regular
Joined
Oct 7, 2018
Messages
91
Hi All,


Just trying to get a formula in workbook A to get Month to date figures from the data below in workbook B, say I need to get the Apple figure up to May, so in workbook A i had May in the title cell A1 but in A2 i should use the formula to get the sum of $26. I tried sum(if but this can only add one column rather than multiple columns, also tried sum(offset but this does not work with the data in a different workbook data and lastly tried to concatenate sum formula from Range Column A to Nth Column dependence on the month but cannot get the sting into a formula even using indirect. Any better suggestion would be much appreciated. thanks for your help. Cheers, Peter




ABCDEFGHIJKLM
1JanFebMarAprMayJunJulAugSepOctNovDec
2Apple712106610621910
3Orange2942881032248
4Mango626530527596

<tbody>
</tbody>
 
Last edited:

Some videos you may like

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Glove_Man

Well-known Member
Joined
Feb 20, 2005
Messages
578
Can you edit Workbook B?

If so, an extra row with 1-12 instead of Jan, Feb etc would allow you to use SUMIF().
 

Glove_Man

Well-known Member
Joined
Feb 20, 2005
Messages
578
Why wouldn't OFFSET work for you?

I got it to work with this:

=SUM(OFFSET('[Workbook B.xlsx]Sheet1'!$B$2,0,0,1,MATCH(A1,'[Workbook B.xlsx]Sheet1'!$B$1:$M$1,0)))
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
42,832
Office Version
365
Platform
Windows
Another option
<b></b><table cellpadding="2.5px" rules="all" style=";background-color: rgb(255,255,255);border: 1px solid;border-collapse: collapse; border-color: rgb(187,187,187)"><colgroup><col width="25px" style="background-color: rgb(218,231,245)" /><col /><col /></colgroup><thead><tr style=" background-color: rgb(218,231,245);text-align: center;color: rgb(22,17,32)"><th></th><th>A</th><th>B</th></tr></thead><tbody><tr ><td style="color: rgb(22,17,32);text-align: center;">1</td><td style="text-align: right;;"></td><td style=";">May</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">2</td><td style=";">Apple</td><td style="text-align: right;;">26</td></tr></tbody></table><p style="width:4em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid rgb(187,187,187);border-top:none;text-align: center;background-color: rgb(218,231,245);color: rgb(22,17,32)">Paste</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: rgb(255,255,255)" ><tr><td style="padding:6px" ><b>Worksheet Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: rgb(255,255,255);border-collapse: collapse; border-color: rgb(187,187,187)"><thead><tr style=" background-color: rgb(218,231,245);color: rgb(22,17,32)"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">B2</th><td style="text-align:left">=SUMPRODUCT(<font color="Blue">(<font color="Red">[Book1]Sheet1!$A$2:$A$4=A2</font>)*(<font color="Red">MONTH(<font color="Green">[Book1]Sheet1!$B$1:$M$1&1</font>)<=MONTH(<font color="Green">B1&1</font>)</font>),[Book1]Sheet1!$B$2:$M$4</font>)</td></tr></tbody></table></td></tr></table><br />
 

peter8848

Board Regular
Joined
Oct 7, 2018
Messages
91
Hi Glove_Man,

Thanks for your reply.

It just i some post saying it will not work with external workbook while i could not work it out. Also could yours work in a range like what Flutt had? Just want to learn if possible and what does that ,0,0,1 stand for in "Sheet1'!$B$2,0,0,1"?

Cheers,

Peter
 

peter8848

Board Regular
Joined
Oct 7, 2018
Messages
91
Hi Fluff,

You are a champion and it works!!!!

Sorry just wondering what is that &1 before the two brackets stand for? thanks for your help again.

Cheers,

Peter
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
42,832
Office Version
365
Platform
Windows
You're welcome & thanks for the feedback
It enables xl to convert a text month such as Aug into a number (ie 8)
 

peter8848

Board Regular
Joined
Oct 7, 2018
Messages
91
Hi Fluff,

Sorry one more question please, if is possible to amend your formula a bit to get the average of these value instead of the sum?

Thanks in advance.

Peter
 

Watch MrExcel Video

Forum statistics

Threads
1,102,633
Messages
5,488,022
Members
407,617
Latest member
Samanthad2007

This Week's Hot Topics

  • Timer in VBA - Stop, Start, Pause and Reset
    [CODE=vba][/CODE] Option Explicit Dim CmdStop As Boolean Dim Paused As Boolean Dim Start Dim TimerValue As Date Dim pausedTime As Date Sub...
  • how to updates multiple rows in muliselect listbox
    Hello everyone. I need help with below code. code is only chaning 1st row in mulitiselect list box. i know issue with code...
  • Delete Row from Table
    I am trying to delete a row from a table using VBA using a named range to find what I need to delete. My Range is finding the right cell. In the...
  • Assigning to a variable
    I have a for each block where I want to assign the value in column 5 of the found row to the variable Serv. [CODE=vba] For Each ws In...
  • Way to verify information
    Hi All, I don't know what to call this formula, and therefore can't search. I have a spreadsheet with information I want to reference...
  • Active Cell Address – Inactive Sheet
    How to use VBA to get the cell address of the active cell in an inactive worksheet and then place that cell address in a location on the current...
Top