Looking to sumif data from month 1 to N

SmileItOff

New Member
Joined
Jan 27, 2017
Messages
8
Hello Misters/Misses,

I'm trying to setup a table for some Year-to-Date data from a massive list. Would like to have a formula/vba that pulls different data and sum/count them from month 1 to N, in which N serves as an input. For example, user (my boss) input 4 as April, the table then pulls the data from month 1 to 4, and so on.

Please help.

Thank you!
Sm: )e
 
Last edited:

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Hi,

It would be helpful to help you if you provide a sample of the layout you're using.

May be something like this?


Book1
ABCDEFGHIJKLMNO
1Jan-2018Feb-2018Mar-2018Apr-2018May-2018Jun-2018Jul-2018Aug-2018Sep-2018Oct-2018Nov-2018Dec-2018Input4
2100200300400500600700800900100011001200Total1000
Sheet79
Cell Formulas
RangeFormula
O2=SUMPRODUCT((MONTH(A1:L1)<=O1)*(A2:L2))
 
Upvote 0
Hi,

It would be helpful to help you if you provide a sample of the layout you're using.

May be something like this?

ABCDEFGHIJKLMNO
Input
Total

<tbody>
[TD="align: center"]1[/TD]
[TD="align: right"]Jan-2018[/TD]
[TD="align: right"]Feb-2018[/TD]
[TD="align: right"]Mar-2018[/TD]
[TD="align: right"]Apr-2018[/TD]
[TD="align: right"]May-2018[/TD]
[TD="align: right"]Jun-2018[/TD]
[TD="align: right"]Jul-2018[/TD]
[TD="align: right"]Aug-2018[/TD]
[TD="align: right"]Sep-2018[/TD]
[TD="align: right"]Oct-2018[/TD]
[TD="align: right"]Nov-2018[/TD]
[TD="align: right"]Dec-2018[/TD]
[TD="align: right"][/TD]

[TD="align: right"]4[/TD]

[TD="align: center"]2[/TD]
[TD="align: right"]100[/TD]
[TD="align: right"]200[/TD]
[TD="align: right"]300[/TD]
[TD="align: right"]400[/TD]
[TD="align: right"]500[/TD]
[TD="align: right"]600[/TD]
[TD="align: right"]700[/TD]
[TD="align: right"]800[/TD]
[TD="align: right"]900[/TD]
[TD="align: right"]1000[/TD]
[TD="align: right"]1100[/TD]
[TD="align: right"]1200[/TD]
[TD="align: right"][/TD]

[TD="align: right"]1000[/TD]

</tbody>
Sheet79

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<tbody>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
[TR]
[TH="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]O2[/TH]
[TD="align: left"]=SUMPRODUCT((MONTH(A1:L1)<=O1)*(A2:L2))[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]

Hello J,

Thank you! Let me provide you with an example to better explain my question:

[TABLE="width: 505"]
<tbody>[TR]
[TD]Position[/TD]
[TD]Time elapsed[/TD]
[TD]location[/TD]
[TD]Date closed[/TD]
[TD]Month[/TD]
[/TR]
[TR]
[TD]Position 1[/TD]
[TD]0-30[/TD]
[TD]location 1[/TD]
[TD]4/2/2018[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]Position 2[/TD]
[TD]30-61[/TD]
[TD]location 2[/TD]
[TD]5/19/2018[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]Position 3[/TD]
[TD]61-90[/TD]
[TD]location 3[/TD]
[TD]1/28/2018[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]Position 4[/TD]
[TD]61-90[/TD]
[TD]location 1[/TD]
[TD]6/5/2018[/TD]
[TD]6[/TD]
[/TR]
[TR]
[TD]Position 5[/TD]
[TD]61-90[/TD]
[TD]location 5[/TD]
[TD]2/15/2018[/TD]
[TD]2[/TD]
[/TR]
</tbody>[/TABLE]

This is how my data look like. I'm looking for a formula or vba code that counts the number of appearances of each criteria from month 1 to N.

Like if I want to know how many positions were filled within 61-90 days from Month 1-3, it would return 2. Whereas if I want to know the same for month 1-6, it would return 3.

Thank you very much!
Sm: )e
 
Upvote 0
Thanks for posting sample data.

If you have the COUNTIFS function:


Book1
ABCDEFGHI
1PositionTime elapsedlocationDate closedMonthCriteriaTo MonthResult
2Position 10-30location 14/2/2018461-9032
3Position 230-61location 25/19/2018530-6140
4Position 361-90location 31/28/2018161-9063
5Position 461-90location 16/5/201860-3051
6Position 561-90location 52/15/20182
Sheet84
Cell Formulas
RangeFormula
I2=COUNTIFS(B$2:B$6,G2,E$2:E$6,"<="&H2)


Enter your criterion in G and H, I formula copied down.
 
Last edited:
Upvote 0
Thank you very much! It worked! This is way more comprehensive than I thought. I was thinking about something like factorial in mathematics to solve this problem LOL
Mind if I ask, why it needs an & sign in between "<=" and the referencing cell?

Thank you!!
 
Upvote 0

Forum statistics

Threads
1,223,901
Messages
6,175,277
Members
452,629
Latest member
SahilPolekar

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