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

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
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,223,911
Messages
6,175,333
Members
452,636
Latest member
laura12345

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