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.

MonthQuarter
1q1
2q2
3q2
4q2
5may
6jun
7jul
8aug
9sep
10oct
11q1
12q1

<colgroup><col width="64" span="2" style="width:48pt"> </colgroup><tbody>
</tbody>

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 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
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,214,983
Messages
6,122,588
Members
449,089
Latest member
Motoracer88

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