+ Reply to Thread
Results 1 to 7 of 7

Macro to Extract Time from Columns Containing Dates

  1. #1
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,725

    Macro to Extract Time from Columns Containing Dates

    I have Dates and Times in Cols B & D from row 2 onwards

    I have tried to write code to move the Times from Col B to C and from Col D to E but cannot get this to work


    Kindly test & amend my code

    Please Login or Register  to view this content.

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Macro to Extract Time from Columns Containing Dates

    Hi I would suggest the following
    Please Login or Register  to view this content.
    DON'T USE .VAlue
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    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,463

    Re: Macro to Extract Time from Columns Containing Dates

    The code works. You just need to format the cells as Time instead of Date.

    At least, I’m assuming the code works as the cells have Time values in them but are formatted as Date.
    Last edited by TMS; 04-30-2023 at 03:33 AM.
    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


  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Macro to Extract Time from Columns Containing Dates

    Can be done easily with a formula:

    =MOD(B2,1)
    =MOD(D2,1)

    Format columns C and E as TIME.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  5. #5
    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,463

    Re: Macro to Extract Time from Columns Containing Dates

    VBA, no loop

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,725

    Re: Macro to Extract Time from Columns Containing Dates

    Many Thanks for the help, much appreciated

  7. #7
    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,463

    Re: Macro to Extract Time from Columns Containing Dates

    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] Extract time across columns in blocks of 30 minutes
    By jeffreybrown in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-17-2021, 08:17 PM
  2. Replies: 6
    Last Post: 02-26-2021, 01:37 PM
  3. [SOLVED] Extract record on multiple dates criteria & copy to different sheet with macro
    By sanjuss2 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-21-2019, 03:25 AM
  4. [SOLVED] Macro that compares 2 dates. I need to extract just date, first
    By lcgar in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-29-2016, 10:36 AM
  5. [SOLVED] macro needed to extract specific columns out of multiple columns with their row data
    By genetist in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-07-2014, 12:49 AM
  6. Replies: 5
    Last Post: 11-15-2010, 10:56 PM
  7. Macro to extract specific Columns
    By bholabhala in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-13-2010, 07:45 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