VBA convert date to text

Shadkng

Active Member
Joined
Oct 11, 2018
Messages
370
Hi, in the below snippet of code I need help in revising the code so range ("G15"), which is a date can be changed to text. Currently when we enter the date in that field we do so as 052324 and it changes to appear as 5/23/24. But when the date moves to the outlook email it shows as 52324. I want it to appear as 5/23/24 if possible. Thanks for the help.

VBA Code:
With oMail
        .SentOnBehalfOfName = "sales@rfbcorp.com"
        .To = Worksheets("DETAIL FORM").Range("G3")
        .cc = ""
        .HTMLBody = "See attached order confirmation. Your order will be released for production. Please notify us immediately if any changes are needed." & "<br/>" & "<br/>" _
                   & "Estimated ship date: " & Sheets("FINALORDER").Range("G15") & "<br/>" & "<br/>" _
                   & "Thank You" & "<br/>" & "<br/>" _
 
Another option:
In your code in post #1, try using .Text property:
Rich (BB code):
With oMail
        .SentOnBehalfOfName = "sales@rfbcorp.com"
        .To = Worksheets("DETAIL FORM").Range("G3")
        .cc = ""
        .HTMLBody = "See attached order confirmation. Your order will be released for production. Please notify us immediately if any changes are needed." & "<br/>" & "<br/>" _
                   & "Estimated ship date: " & Sheets("FINALORDER").Range("G15").Text & "<br/>" & "<br/>" _
                   & "Thank You" & "<br/>" & "<br/>" _
 
Upvote 0

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Another option might be

VBA Code:
Dim Holder As String
Holder = Format(Sheets("FINALORDER").Range("G15"), "0\/00\/00")

With oMail
        .SentOnBehalfOfName = "sales@rfbcorp.com"
        .To = Worksheets("DETAIL FORM").Range("G3")
        .cc = ""
        .HTMLBody = "See attached order confirmation. Your order will be released for production. Please notify us immediately if any changes are needed." & "<br/>" & "<br/>" _
                   & "Estimated ship date: " & Holder & "<br/>" & "<br/>" _
                   & "Thank You" & "<br/>" & "<br/>" _
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,287
Members
452,631
Latest member
a_potato

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