View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
isabelle isabelle is offline
external usenet poster
 
Posts: 587
Default End of Quarter Based on Fiscal Year

hi Michael,

Sub Macro1()
Dim n As Date, y As Integer, endY As Date, startY As Date
Dim t As Date, t1 As Date, t2 As Date, t3 As Date

n = DateSerial(2011, 12, 21)

If Month(n) <= 10 And Day(n) <= 31 Then y = Year(n) Else y = Year(n) + 1
endY = DateSerial(y, 10, 31)
startY = DateSerial(Year(endY) - 1, Month(endY), Day(endY) + 1)
t1 = DateSerial(Year(startY), Month(startY) + 3, Day(startY) - 1)
t2 = DateSerial(Year(startY), Month(startY) + 6, Day(startY) - 1)
t3 = DateSerial(Year(startY), Month(startY) + 9, Day(startY) - 1)

Select Case n
Case Is startY: t = t1
Case Is t1: t = t2
Case Is t2: t = t3
Case Is t2: t = endY
End Select

Debug.Print t
End Sub


--
isabelle



Le 2011-12-21 12:37, Michael a écrit :
I am trying to come up with a fuction that takes a date and depending
on the month that the fiscal year ends return the last day of the
quarter. For example date 12/21/2011 on a fiscal year that ends Oct 31
would return 1/31/2012.

Basicly I am trying to round dates up to the date at the end of the
fiscal quarter it falls in.

any help would be appreciated