View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Robert Robert is offline
external usenet poster
 
Posts: 193
Default Fiscal Quarter code not working

This code works when x = a date, but if the cell is blank it displays a "2"
not the error message Case Else should display. Any ideas why?

Function GetFiscalQuarter(ByVal x As Date) 'this works as variant also
Dim Qtr As Date 'this works as integer or variant
Qtr = DatePart("m", x)

Select Case Qtr
Case 7, 8, 9
Qtr = "1"
Case 10, 11, 12
Qtr = "2"
Case 1, 2, 3
Qtr = "3"
Case 4, 5, 6
Qtr = "4"
Case Else
Qtr = "error" 'this doesn't work at all!!!!
End Select

GetFiscalQuarter = Qtr

End Function

--
Robert