Public Function DetermineLnmSendDate(cbaYes As Boolean, cbaDate As Date, lnmDate As Date, newCBA As Variant, newVM As Variant) As Date Dim aryRange() As Date Dim dtSendDate As Date Dim i As Integer Dim tmpDate As Date If cbaYes = False Then If FirstSend(lnmDate) = True Then 'If this is the first time LNM has ben scheduled dtSendDate = Date 'Send it today Else 'If Not dtSendDate = lnmDate + 30 'Send it in 30 days from the last send date End If Else 'cbaYes = True If FirstSend(cbaDate) = True Then 'If this is the first time CBA has been scheduled dtSendDate = Date + 14 'Send it in 14 days from todays date Else 'If Not dtSendDate = cbaDate + 14 'Send it 14 days from the last CBA send date End If End If 'The following is to make sure the selected date doesn't fall on the same week as the other marketing blasts aryRange = WeekRange(dtSendDate) i = 1 If newCBA <> "N/A" Then tmpDate = CDate(newCBA) Do While i <= 7 If tmpDate = aryRange(i) Then dtSendDate = dtSendDate + 7 Exit Do End If i = i + 1 Loop i = 1 End If If newVM <> "N/A" Then tmpDate = CDate(newVM) Do While i <= 7 If tmpDate = aryRange(i) Then dtSendDate = dtSendDate + 7 Exit Do End If i = i + 1 Loop End If 'Set the next marketing date DetermineLnmSendDate = dtSendDate End Function Public Function FirstSend(dtCell As Date) As Boolean 'Is it the first time the property has been marketed on the referenced platform? If dtCell = 0 Then FirstSend = True Else FirstSend = False End If End Function Public Function WeekRange(dtInQuestion As Date) As Date() Dim tmpArray(1 To 7) As Date Dim i As Integer Dim dtStartDate As Date dtStartDate = dtInQuestion i = Weekday(dtInQuestion) 'Find the upper bounds of the week array Do While i <= 7 tmpArray(i) = dtStartDate dtStartDate = dtStartDate + 1 i = i + 1 Loop 'Reset i value to find lower bounds i = Weekday(dtInQuestion) dtStartDate = dtInQuestion 'Find lower bounds of the week array Do While i >= 1 tmpArray(i) = dtStartDate dtStartDate = dtStartDate - 1 i = i - 1 Loop WeekRange = tmpArray End Function