Populate Based on Month and Year

kumara_faith

Well-known Member
Joined
Aug 19, 2006
Messages
922
Office Version
  1. 365
Hi,

I have a table as below:
Book2
CDEFGH
2DateMonthly BonusYearly BonusMonthly Bonus500
314/1/2020500Yearly Bonus2000
415/1/2020
516/1/2020
617/1/2020
718/1/2020
819/1/2020
920/1/2020
1021/1/2020
1122/1/2020
1223/1/2020
135/2/2020500
146/2/2020
157/2/2020
168/2/2020
179/2/2020
1810/2/2020
1915/3/2020500
2016/3/2020
2117/3/2020
2218/3/2020
2319/3/2020
2420/3/2020
2521/3/2020
264/1/20212000
275/1/2021
286/1/2021
297/1/2021
308/1/2021
Sheet1


I need to insert the monthly bonus of USD500 at the earliest date of the month and the yearly bonus of USD 2000 at the earliest date of the following year. I am working on a list of a few years. Is there a formula that I could use to automate this ? Appreciate all the help.
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Why does the 1st in Jan 2020 have a monthly bonus & not a yearly one, whereas the 1st date in Jan 21 is the otherway round?
 
Upvote 0
EDIT
Just seen the reply from Fluff as I hit the post button

so ignore below

i have used a couple of IF () to get the info
just not the 1st, will work on or someone else may have a better solution

Book1
ABCDEF
1DateMonthly BonusYearly BonusMonthly Bonus500
21/14/20#VALUE!#VALUE!Yearly Bonus2000
31/15/20  
41/16/20  
51/17/20  
61/18/20  
71/19/20  
81/20/20  
91/21/20  
101/22/20  
111/23/20  
122/5/20500 
132/6/20  
142/7/20  
152/8/20  
162/9/20  
172/10/20  
183/15/20500 
193/16/20  
203/17/20  
213/18/20  
223/19/20  
233/20/20  
243/21/20  
251/4/21 2000
261/5/21  
271/6/21  
281/7/21  
291/8/21  
Sheet1
Cell Formulas
RangeFormula
B2:B29B2=IF(AND(YEAR(A1)=YEAR(A2),MONTH(A2)<>MONTH(A1)),$F$1,"")
C2:C29C2=IF(AND(YEAR(A1)<>YEAR(A2)),$F$2,"")
 
Upvote 0
Hi Kamara_Faith,

I'm assuming 14 Jan 20 should also have a yearly bonus as it's the first date of 2020.

Kumara_Faith.xlsx
CDEFGH
2DateMonthly BonusYearly BonusMonthly Bonus500
314-Jan-205002000Yearly Bonus2000
415-Jan-20  
516-Jan-20  
617-Jan-20  
718-Jan-20  
819-Jan-20  
920-Jan-20  
1021-Jan-20  
1122-Jan-20  
1223-Jan-20  
1305-Feb-20500 
1406-Feb-20  
1507-Feb-20  
1608-Feb-20  
1709-Feb-20  
1810-Feb-20  
1915-Mar-20500 
2016-Mar-20  
2117-Mar-20  
2218-Mar-20  
2319-Mar-20  
2420-Mar-20  
2521-Mar-20  
2604-Jan-215002000
2705-Jan-21  
2806-Jan-21  
2907-Jan-21  
3008-Jan-21  
Sheet1
Cell Formulas
RangeFormula
D3:D30D3=IF(C3=AGGREGATE(15,6,$C$3:$C$30/(($C$3:$C$30>=DATE(YEAR(C3),MONTH(C3),1))*($C$3:$C$30<=EOMONTH(C3,0))),1),$H$2,"")
E3:E30E3=IF(C3=AGGREGATE(15,6,$C$3:$C$30/(($C$3:$C$30>=DATE(YEAR(C3),1,1))*($C$3:$C$30<=DATE(YEAR(C3),12,31))),1),$H$3,"")
 
Upvote 0
One question: the first cell is 14/01 but is given a monthly bonus and not yearly. Shouldn't this get an yearly bonus? As it is the earliest date of the year 2020?

Either way here is my suggestion. This should work:

Monthly Bonus
=IF(SUMPRODUCT(1*(MONTH($A$2:A2)=MONTH(A2)))>1,"",500)

Yearly Bonus
=IF(SUMPRODUCT(1*(YEAR($A$2:A2)=YEAR(A2)))>1,"",2000)

Much like Toadstool I have also assumed that the turn of the new year gets both a montly and yearly salary.
 
Upvote 0
Another possible option
+Fluff 1.xlsm
CDEFGH
1
2DateMonthly BonusYearly BonusMonthly Bonus500
314/01/20205002000Yearly Bonus2000
415/01/2020
516/01/2020
617/01/2020
718/01/2020
819/01/2020
920/01/2020
1021/01/2020
1122/01/2020
1223/01/2020
1305/02/2020500
1406/02/2020
1507/02/2020
1608/02/2020
1709/02/2020
1810/02/2020
1915/03/2020500
2016/03/2020
2117/03/2020
2218/03/2020
2319/03/2020
2420/03/2020
2521/03/2020
2604/01/20215002000
2705/01/2021
2806/01/2021
2907/01/2021
3008/01/2021
31
Main
Cell Formulas
RangeFormula
D3:D30D3=IF((YEAR(C3:C30)>IFERROR(YEAR(C2:C29),0))+(MONTH(C3:C30)>IFERROR(MONTH(C2:C29),0)),H2,"")
E3:E30E3=IF(YEAR(C3:C30)>IFERROR(YEAR(C2:C29),0),H3,"")
Dynamic array formulas.
 
Upvote 0
Solution
Hi Fluff, Martunis, Toadstool and etaf,

My apologies. Yes, January 2020 and January 2021 should have both monthly bonus and yearly bonus.

Thank you for your valuable time and patience. Appreciate all the solutions and it worked. Have a blessed day ahead everyone.?
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,523
Messages
6,120,038
Members
448,940
Latest member
mdusw

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