Excel VBA- If Then statement

  • Thread starter Thread starter tam76131
  • Start date Start date
T

tam76131

Please help. I need to write a couple lines of codes in excel to tel
the worksheet if it's month 1,2,3 then place a certain in qtr1, if th
month number is 4,5,6 then place the value in qtr2. I don' think it'
too complicated but being new to vba.....i'm helpless....thanks for al
your help.

Tam
 
Do you mean in VBA?

This returns the qtr of the current date

int((month(date)-1)/ 3)+1

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
The Select Case statement is designed for this type
of "multiple condition 'if'"

Select Case MonthNo
Case 1, 2, 3
qtr1 = .....
Case 4, 5, 6
qtr2 = ....
Case 7, 8, 9
qtr3 = ...
Case Else
qtr4 = ...
End Select
 
For another possibility (not the best, IMO)

=DatePart("Q",DateSerial(2004,MonthNo,1))

The best, I think, is the first suggestion you got.
 

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

Back
Top