View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
[email protected] brett.kaplan@gmail.com is offline
external usenet poster
 
Posts: 48
Default Custom Format for User Defined Function

Awesome, thanks!


mrice wrote:
Try this pair of functions



Function Window(Cell1, Cell2)
Year1 = Day(Cell1)
Year2 = Day(Cell2)
Month1 = Month(Cell1)
Month2 = Month(Cell2)
Month1 = ConvertToNamedMonth(Month1)
Month2 = ConvertToNamedMonth(Month2)
Window = Year1 & "-" & Month1 & " - " & Year2 & "-" & Month2
End Function

Function ConvertToNamedMonth(MonthNumber)
Select Case MonthNumber
Case Is = 1
ConvertToNamedMonth = "Jan"
Case Is = 2
ConvertToNamedMonth = "Feb"
Case Is = 3
ConvertToNamedMonth = "Mar"
Case Is = 4
ConvertToNamedMonth = "Apr"
Case Is = 5
ConvertToNamedMonth = "May"
Case Is = 6
ConvertToNamedMonth = "Jun"
Case Is = 7
ConvertToNamedMonth = "Jul"
Case Is = 8
ConvertToNamedMonth = "Aug"
Case Is = 9
ConvertToNamedMonth = "Sep"
Case Is = 10
ConvertToNamedMonth = "Oct"
Case Is = 11
ConvertToNamedMonth = "Nov"
Case Is = 12
ConvertToNamedMonth = "Dec"
End Select
End Function


--
mrice

Research Scientist with many years of spreadsheet development experience
------------------------------------------------------------------------
mrice's Profile: http://www.excelforum.com/member.php...o&userid=10931
View this thread: http://www.excelforum.com/showthread...hreadid=569198