Assign quarter dynamically based on the starting month

Shweta

Well-known Member
Joined
Jun 5, 2011
Messages
514
Hello All,

I have a data validation list for all the months from January to December. I want to assign quarters to my months based on the selection in the validation list.

For example, If "November (11)" is selected in the validation list, Q1 should be May-July and Q2 should be Aug-Oct. And for rest of the period, I want month itself.

[TABLE="width: 128"]
<colgroup><col width="64" span="2" style="width:48pt"> </colgroup><tbody>[TR]
[TD="class: xl65, width: 64"]Month[/TD]
[TD="class: xl65, width: 64"]Quarter[/TD]
[/TR]
[TR]
[TD="class: xl66"]1[/TD]
[TD="class: xl66"]q1[/TD]
[/TR]
[TR]
[TD="class: xl66"]2[/TD]
[TD="class: xl66"]q2[/TD]
[/TR]
[TR]
[TD="class: xl66"]3[/TD]
[TD="class: xl66"]q2[/TD]
[/TR]
[TR]
[TD="class: xl66"]4[/TD]
[TD="class: xl66"]q2[/TD]
[/TR]
[TR]
[TD="class: xl66"]5[/TD]
[TD="class: xl66"]may[/TD]
[/TR]
[TR]
[TD="class: xl66"]6[/TD]
[TD="class: xl66"]jun[/TD]
[/TR]
[TR]
[TD="class: xl66"]7[/TD]
[TD="class: xl66"]jul[/TD]
[/TR]
[TR]
[TD="class: xl66"]8[/TD]
[TD="class: xl66"]aug[/TD]
[/TR]
[TR]
[TD="class: xl66"]9[/TD]
[TD="class: xl66"]sep[/TD]
[/TR]
[TR]
[TD="class: xl66"]10[/TD]
[TD="class: xl66"]oct[/TD]
[/TR]
[TR]
[TD="class: xl66"]11[/TD]
[TD="class: xl66"]q1[/TD]
[/TR]
[TR]
[TD="class: xl66"]12[/TD]
[TD="class: xl66"]q1[/TD]
[/TR]
</tbody>[/TABLE]

Above is the table for what exactly I want.

Please help with an appropriate formula or vba code.

Thanks in advance!

Regards,
Shweta Jain
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
No doubt someone more clever can make a much better formula, but at least this one will get you on your way.

In A2 is the Data Validation cell that uses the field Month (i.e., A6:A17) as its List of allowable values. Choose a month in A2 and the table will populate with "q1" for that month and the next two, "q2" for the subsequent three months, and the month's name for the remainder. Copy A6 and C6 downwards to populate the cells.

[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]
Book1
ABC
1
2Nov11
3
4
5MonthMonth#Quarter
6Jan1q1
7Feb2q2
8Mar3q2
9Apr4q2
10May5May
11Jun6Jun
12Jul7Jul
13Aug8Aug
14Sep9Sep
15Oct10Oct
16Nov11q1
17Dec12q1
Sheet46
Cell Formulas
RangeFormula
B2=MONTH(DATEVALUE(A2&" 1"))
A6=TEXT(B6*29,"MMM")
C6=IF(OR(B6=IF($B$2+{0;1;2}>12,$B$2+{0;1;2}-12,$B$2+{0;1;2})),"q1",IF(OR(B6=IF($B$2+{3;4;5}>12,$B$2+{3;4;5}-12,$B$2+{3;4;5})),"q2",A6))
[/FONT]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,286
Members
452,631
Latest member
a_potato

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