+ Reply to Thread
Results 1 to 6 of 6

modify vba to autoincrement hours

  1. #1
    Forum Contributor
    Join Date
    12-03-2008
    Location
    Key West, FL
    MS-Off Ver
    365 Apps for Enterprise
    Posts
    665

    modify vba to autoincrement hours

    Happy Holidays everyone!

    This is a VBA a member here wrote for me to convert a series of days into a series of days/ with 24 hours having a unique format for the hours (T00, T01, T02... T24).

    Could someone help me modify it so that the output is now more conventional (still incremented hourly) in this format: 2017-11-30 21:00:00, 2017-11-30 22:00:00, 2017-11-30 00:00:00 etc?

    I've tried but had no success in getting the hours to increment properly.


    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,150

    Re: modify vba to autoincrement hours

    Quote Originally Posted by jrtaylor View Post
    ... modify it so that the output is now more conventional ... format:
    2017-11-30 21:00:00, 2017-11-30 22:00:00, 2017-11-30 00:00:00 etc ...
    Maybe this way:
    Please Login or Register  to view this content.
    but a lot depends on system settings (date, time, separators).

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: modify vba to autoincrement hours

    jrtaylor

    Is this how you wanted?
    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    12-03-2008
    Location
    Key West, FL
    MS-Off Ver
    365 Apps for Enterprise
    Posts
    665

    Re: modify vba to autoincrement hours

    Thanks! I'll try both. I see that the first is code which fits into the existing macro, while the second is a full macro?

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: modify vba to autoincrement hours

    Correct and my code is assuming ColA in original data have Dates without time.

    If you have Date + Time in Original Data then change to
    Please Login or Register  to view this content.

  6. #6
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,150

    Re: modify vba to autoincrement hours

    And watch out for your system date and use the appropriate '.NumberFormat' depending on that, i.e.: "yyyy-mm-dd hh:mm:ss" or "yyyy/mm/dd hh:mm:ss" (e.g. for non-english european date format in comp system).
    Last edited by mjr veverka; 12-26-2017 at 10:39 AM.

+ 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] How to stop autoincrement in formula
    By cinu97 in forum Excel General
    Replies: 3
    Last Post: 05-19-2015, 10:44 PM
  2. Autoincrement Vlookup While copying down a column
    By Unimog1 in forum Excel General
    Replies: 1
    Last Post: 01-19-2015, 03:44 PM
  3. Autoincrement a single cell on a template
    By maddmikk in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-18-2013, 06:37 PM
  4. [SOLVED] Calculate hours with predefined Working Hours and Weekend Hours
    By garciapliz in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-05-2013, 11:17 AM
  5. Autoincrement field including year - Restart each year
    By lesoies in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-30-2012, 10:54 AM
  6. [SOLVED] if there is data in B12* autoincrement A12 number
    By zit1343 in forum Excel General
    Replies: 3
    Last Post: 04-09-2012, 12:00 PM
  7. Export some cells from Invoice to Master and viceversa(autoincrement feature)
    By Rober in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 02-13-2012, 01:57 AM

Tags for this Thread

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