Works perfectly!!! And much less convoluted than what I proposed to Bob,
although I still think it could be accomplished and with less code. I do
like your single function approach over the dual functions, though.
Many thanks.
You're welcome. Glad to help.
By the way, it can be made a little shorter even with the same algorithm by
deleting some stuff that is extraneous to the current routine.
But sometimes it's best to make things a little more lengthy, so as to lead to
easier maintenance.
But here's a bit shorter variation:
==========================
Sub BiMonthlyDt()
Dim rg1 As Range, rg2 As Range
Dim dy As Long
Dim Suffix As String
Dim Fmt As String
Const Quote As String = """"
Const P1 As String = """From: """
Const P2 As String = """To: """
Const DtFmt1 As String = "mmm d"
Const DtFmt2 As String = " yyyy"
Set rg1 = Range("A2")
Set rg2 = Range("C2")
If Not (IsDate(rg1.Value)) Then _
rg1.Value = DateSerial(Year(Date), Month(Date), 0)
dy = Day(rg1.Value)
Select Case dy
Case Is = 1
rg1.Value = rg1.Value + 15
rg2.Value = DateSerial(Year(rg1.Value), Month(rg1.Value) + 1, 0)
Case Else
rg1.Value = DateSerial(Year(rg1.Value), Month(rg1.Value) + 1, 1)
rg2.Value = rg1.Value + 14
End Select
dy = Day(rg1.Value)
Suffix = Quote & OrdinalSuffix(dy) & Quote
Fmt = P1 & DtFmt1 & Suffix
rg1.NumberFormat = Fmt
dy = Day(rg2.Value)
Suffix = Quote & OrdinalSuffix(dy) & Quote
Fmt = P2 & DtFmt1 & Suffix & DtFmt2
rg2.NumberFormat = Fmt
End Sub
Function OrdinalSuffix(Num) As String
Dim Suffix As String
If Not IsNumeric(Num) Then Exit Function
If Num <> Int(Num) Then Exit Function
Select Case Num Mod 10
Case Is = 1
Suffix = "st"
Case Is = 2
Suffix = "nd"
Case Is = 3
Suffix = "rd"
Case Else
Suffix = "th"
End Select
OrdinalSuffix = Suffix
End Function
============================
Best,
--ron