issue displaying date with applied format

Bill_Davenport

New Member
Joined
Jul 25, 2017
Messages
13
Hello,

I currently have a script dumping information into an email however the date format in my spreadsheet is too long and i'd like to cut it down to just display the Hour currently the date is formatted like this:

01/08/2017 8:00:00 AM

and I would prefer to just show 8 (8am basically) and dump it into an email however when i do this the date format is getting messed up and it shows up weird.

this is the code i'm using to format the date to only show the hour, which works in excel.
Code:
Selection.NumberFormat = "h"

this is the code i'm using to dump it into an email
Code:
With OutMail
        .To = distgrp
        .CC = cclist
        .BCC = ""
        .Subject = "*URGENT* " & Range("H" & i).Value & " - Not ready " & Range("F" & i).Value & " to " & Range("G" & i).Value & ". Order# " & Range("B" & i).Value
        .HTMLBody = strbody
        .Display
    End With

when i run this code the subject line is showing up *URGENT* North - Not ready 42948.3333333333

any suggestions on how i can have this display just the hour instead of 42948.3333?

thanks!
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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