+ Reply to Thread
Results 1 to 8 of 8

& Range formats to serial time I need hh:mm?

  1. #1
    Registered User
    Join Date
    02-26-2016
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    42

    & Range formats to serial time I need hh:mm?

    I have an issue with VBA and the time format changing to serial time. I need to retain hh:mm format.
    Here is my issue:

    With OutMail
    .To = strEmail
    .cc = ccEmail
    .BCC = ""
    .Subject = "Info - " & Range("A" & x) & "/" & Range("B" & x) & "/" & Range("D" & x) & " - " & Range("U" & x)


    Currently my email subject line looks like this:
    Info - AAA/BBB/0.350694444444444 - UUU

    Where I need it to look like this:
    Info - AAA/BBB/08:25 - UUU


    My time format in Column "D" is ("hh:mm") due other reasons so I can't change the formatting of that column.
    Is there a way to keep the 08:25 format vs it resetting to 0.350694444444444

    I tried .Numberformat etc but I think due to "D" & x variable I'm not sure If I should be trying to format the "D" or the variable x

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,430

    Re: & Range formats to serial time I need hh:mm?

    This: Range("D" & x) needs to be this: Format(Range("D" & x), "hh:mm")
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,885

    Re: & Range formats to serial time I need hh:mm?

    Or you can use Range("D" & x).Text to pass on formatted text from cell. But TMS's method may be faster as reading formatted text from cell is usually slower process.
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,430

    Re: & Range formats to serial time I need hh:mm?

    Ha, always forget about .Text. Just use what I've always used

  5. #5
    Registered User
    Join Date
    02-26-2016
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    42

    Re: & Range formats to serial time I need hh:mm?

    TMS, Ahh.. Apply before the Range. I was trying to apply to the column ("d") or the variable x.
    Worked great much thanks for the solution.

  6. #6
    Registered User
    Join Date
    02-26-2016
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    42

    Re: & Range formats to serial time I need hh:mm?

    CK76 thanks! Only one line of code so the .text is also a great & easy solution!
    Cheers!

  7. #7
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,885

    Re: & Range formats to serial time I need hh:mm?

    You are welcome and thanks for the rep

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,430

    Re: & Range formats to serial time I need hh:mm?

    You're welcome. Thanks for the rep.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] using vba get the serial number of time portion of date and time cell
    By jprlimey in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-13-2020, 05:04 PM
  2. adding time and changing formats from time of day into total minutes
    By ryu666 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-13-2018, 06:47 AM
  3. Find duplicate serial numbers when present in two different formats
    By adamdoldfield in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-28-2014, 11:37 PM
  4. Convert Serial Time
    By jeffwest2 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-25-2013, 04:19 AM
  5. Userform time shows as serial time
    By projectaero in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-30-2010, 05:31 PM
  6. [SOLVED] serial time
    By David Gerstman in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-17-2006, 12:00 PM
  7. time serial number
    By Bob Gotti in forum Excel General
    Replies: 1
    Last Post: 01-19-2006, 06:10 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1