NOW() Formula to accomplish .DeferredDeliveryTime = "Normal Business Hours"

John.McLaughlin

Board Regular
Joined
Jul 19, 2011
Messages
169
Hello,


I send order confirmations via Excel and With Outmail. Currently I use this formula in cell B1 to delay the delivery until 9AM. It works fine if I am entering orders before 9AM.


=IF(NOW()>9/24,TODAY(),TODAY()+1).

Problem is, sometimes I am entering customer orders at night, and I want to hold the delivery until the next business day. Currently I have to change the delivery time by hand in Outlook, Options>Delay Delivery.


How can I change the formula to;



  • If between 9 to 5, send the mail,
  • if before 9, hold until 9,
  • if after 5, hold until the next day at 9am.


Thank you in advance!


John
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
How can I change the formula to;



  • If between 9 to 5, send the mail,
  • if before 9, hold until 9,
  • if after 5, hold until the next day at 9am.

Correction;

The formula; =IF(NOW()>9/24,TODAY(),TODAY()+1) returns a date value in cell B1, I need the formula to return a date based on current Time


  • If between 9 to 5, return todays date
  • if before 9, return todays date,
  • if after 5, return today + 1


Thanks again!
 
Upvote 0
For reference;

I accomplished this with some cobbled code from an Outlook forum.

Code:
Dim obj As Object
    Dim Mail As Outlook.MailItem
    Dim WkDay As String
    Dim MinNow As Integer
    Dim SendHour As Integer
    Dim SendDate As Date
    Dim SendNow As String


'Set Variables
SendDate = Now()
SendHour = Hour(Now)
MinNow = Minute(Now)
WkDay = Weekday(Now)
SendNow = Y


'Check if Before 9am
If SendHour < 9 Then
    SendHour = 9 - SendHour
    SendDate = DateAdd("h", SendHour, SendDate)
    SendDate = DateAdd("n", -MinNow, SendDate)
    SendNow = N
End If
'Check if after 5PM
If SendHour > 17 Then           'After 5 PM
    SendHour = 33 - SendHour    'Send a 8 am next day
'    SendDate = DateAdd("d", 1, SendDate)
    SendDate = DateAdd("h", SendHour, SendDate)
    SendDate = DateAdd("n", -MinNow, SendDate)
    SendNow = N
End If


'Check if Sunday
If WkDay = 1 Then
    SendDate = DateAdd("d", 1, SendDate)
    SendNow = N
End If


'Check if Saturday
If WkDay = 7 Then
    SendDate = DateAdd("d", 1, SendDate)
    SendNow = N
End If

.DeferredDeliveryTime = SendDate
 
Upvote 0

Forum statistics

Threads
1,216,090
Messages
6,128,765
Members
449,467
Latest member
sdafasfasdf

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top