The function below creates a dateserial of a date that I need. But in the end instead of showing up in the cell as a serial I want it to be "mmm-yy". I can do that now if I select the cell after the fact and change the date format. When I try to do it at the end of the function I just get value errors. So any help would be appreciated.
Function MM(d1 As Date) As Long
Dim mnth1 As Integer
Dim y1 As Integer
y1 = Format(d1, "YYYY")
Dim d3 As Date
d3 = DateSerial(y1, 1, 1)
d1 = ((d1 - d3) + 2) / 7
If d1 = Int(d1) Then
GoTo finish
End If
d1 = Int(d1) + 1
finish:
MM = d1
Select Case MM
Case 1 To 5: mnth1 = 1
Case 6 To 9: mnth1 = 2
Case 10 To 13: mnth1 = 3
Case 14 To 18: mnth1 = 4
Case 19 To 22: mnth1 = 5
Case 23 To 26: mnth1 = 6
Case 27 To 31: mnth1 = 7
Case 32 To 35: mnth1 = 8
Case 36 To 39: mnth1 = 9
Case 40 To 44: mnth1 = 10
Case 45 To 48: mnth1 = 11
Case 49 To 52: mnth1 = 12
Case 53: mnth1 = 12
Case Else
End Select
MM = mnth1
MM = DateSerial(y1, MM, 15)
End Function
Thanks for any and all help,
Bookmarks