VBA Formula for 30 minutes less a time value not working the way I need

Status
Not open for further replies.

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,564
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have this code...

VBA Code:
With .cells(rw, 2)
     mm2 = DateAdd("n", -0.5, sh.Cells(rw, 6))
    .Value = "<" & Format(mm2, "h:mmA/P")
End With

The value in sh.Cells(rw,6) = 45075.7916666667 (May 29, 2023 7:00:00 PM)
The result for variable mm2 after the forumal is executed is 2023-05-29 7:00:00 PM

I am looking for mm2 to be 30 minutes less (2023-05-29 6:30:00 PM), but I'm not getting that result.
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Rich (BB code):
mm2 = DateAdd("n", -30, sh.Cells(rw, 6))
 
Upvote 0
Duplicate to: VBA Formula Not Removing 30 Minutes From Time

In future, please do not post the same question multiple times. Per Forum Rules (#12), posts of a duplicate nature will be locked or deleted.

In relation to your question here, I have closed this thread. I have also removed the marked answer from this thread and moved it to post #6 of the linked thread where this exact same answer was provided to you two weeks ago (& not acknowledged by you)
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,223,238
Messages
6,170,939
Members
452,368
Latest member
jayp2104

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