If(And(Month() Issue

M

Mike

I am trying to do a simple task of labeling a row as Q1,Q2,Q3 or Q4
based on the month value of an existing date. I am using the following
IF(AND function but get an error statement which I cannot resolve. Any
suggestions would be welcome. Thanks.

=if(and(month(A2)>=1,<=3,"QTR1",if(and(month(A2)>=4,<=6,"QTR2",if(and(A2)>=7,<=9,"QTR3","QTR4")))
 
N

Niek Otten

=if(and(month(A2)>=1,month(A2)<=3)," etc

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

|I am trying to do a simple task of labeling a row as Q1,Q2,Q3 or Q4
| based on the month value of an existing date. I am using the following
| IF(AND function but get an error statement which I cannot resolve. Any
| suggestions would be welcome. Thanks.
|
| =if(and(month(A2)>=1,<=3,"QTR1",if(and(month(A2)>=4,<=6,"QTR2",if(and(A2)>=7,<=9,"QTR3","QTR4")))
|
 
D

Dave Peterson

=IF(MONTH(A2)<4,"QTR1",IF(MONTH(A2)<7,"QTR2",IF(MONTH(A2)<10,"QTR3","QTR4")))
is one way.

But this will work, too:
="QTR"&INT((MONTH(A2)+2)/3)
 
P

Pete_UK

Hi Mike,

you are using the AND function incorrectly - try this:

=IF(AND(MONTH(A2)>=1,MONTH(A2)<=3),"QTR1",IF(AND(MONTH(A2)>=4,MONTH(A2)<=6),"QTR2",IF(AND(MONTH(A2)>=7,MONTH(A2)<=9),"QTR3","QTR4")))

Alternatively, you might like to try this:

="QTR"&INT((MONTH(A2)+2)/3)

Hope this helps.

Pete
 
M

Mike

Thanks to all of you for your help. Works fine now and I learned
something new.

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top