+ Reply to Thread
Results 1 to 3 of 3

Macro to correct time and date

  1. #1
    Registered User
    Join Date
    07-21-2012
    Location
    London, englan
    MS-Off Ver
    Excel 2007
    Posts
    7

    Macro to correct time and date

    Hello everyone,

    I need to correct the times and dates of about 700 pages of data. The times in my dataset are out by 7 hours (should have only been out by 6 hours, but thats another story) and I need to convert them to local time and date.

    The Times
    I fixed this..They were easy to correct, as I just subtracted the 7 hour difference for the entire column to get the local time.

    The Dates
    I corrected the times but the dates are still in UTC dates, I need local dates. Shown below are the incorrect dates...Basically when the local time reaches midnight I want the local date to increase by a day and then fill the correct date in the corresponding row/columns for local date. Then once the local time reaches midnight again, I want the next day entered into the local date row/columns.

    Incorrect Time UTC | Date (Local) | Time (Local)
    12-06-2013 23:49 | 12-06-2013 | 16:49
    12-06-2013 23:50 | 12-06-2013 | 16:50
    12-06-2013 23:51 | 12-06-2013 | 16:51
    12-06-2013 23:52 | 12-06-2013 | 16:52
    12-06-2013 23:53 | 12-06-2013 | 16:53
    12-06-2013 23:54 | 12-06-2013 | 16:54
    12-06-2013 23:55 | 12-06-2013 | 16:55
    12-06-2013 23:56 | 12-06-2013 | 16:56
    12-06-2013 23:57 | 12-06-2013 | 16:57
    12-06-2013 23:58 | 12-06-2013 | 16:58
    12-06-2013 23:59 | 12-06-2013 | 16:59
    12-07-2013 00:00 | 12-07-2013 | 17:00
    <------- The local date should not change here
    12-07-2013 00:01 | 12-07-2013 | 17:01
    12-07-2013 00:02 | 12-07-2013 | 17:02
    12-07-2013 00:03 | 12-07-2013 | 17:03
    12-07-2013 00:04 | 12-07-2013 | 17:04
    12-07-2013 00:05 | 12-07-2013 | 17:05
    12-07-2013 00:06 | 12-07-2013 | 17:06
    12-07-2013 00:07 | 12-07-2013 | 17:07
    12-07-2013 00:08 | 12-07-2013 | 17:08
    12-07-2013 00:09 | 12-07-2013 | 17:09
    ……………….......…. | …………………. | ………………
    12-07-2013 06:55 | 12-07-2013 | 23:55
    12-07-2013 06:56 | 12-07-2013 | 23:56
    12-07-2013 06:57 | 12-07-2013 | 23:57
    12-07-2013 06:58 | 12-07-2013 | 23:58
    12-07-2013 06:59 | 12-07-2013 | 23:59
    12-07-2013 07:00 | 12-07-2013 | 0:00
    <------- The local date should change here
    12-07-2013 07:01 | 12-07-2013 | 0:01
    12-07-2013 07:02 | 12-07-2013 | 0:02
    12-07-2013 07:03 | 12-07-2013 | 0:03

    I attempted to create a user input box to enter a start date and time. Then the time would increment by 1 minute and the date would not change until it reached midnight, then continue for all 700 pages of data.
    But I failed so far. I have tried loops and if then statements, do whiles...I am getting lost and I cannot seem to get it right. Can someone help me with this?

    I have attached a sample sheet with a incorrect tab and a corrected tab just in case someone don't follow what I want or am trying to accomplish.

    Lost newb
    Attached Files Attached Files
    Last edited by reesjordan; 12-27-2013 at 07:58 AM.

  2. #2
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Macro to correct time and date

    Hi reesjordan,
    try it
    Please Login or Register  to view this content.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    07-21-2012
    Location
    London, englan
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Macro to correct time and date

    nilem,

    This is perfect and exactly what I required. Now I just have to try and figure out what each line of code means/does.

    Thank you, your help is greatly appreciated.

    Jordan

+ 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. Replies: 3
    Last Post: 12-19-2013, 06:49 AM
  2. correct function to find a correct time value
    By jekidi in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 07-06-2013, 03:17 PM
  3. Userform to check Date/Time format correct before copying to worksheet
    By LoneWolf3574 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-16-2013, 05:14 AM
  4. [SOLVED] Show the date and time in a specific cell of last time we run a macro
    By dragon_m0nsta in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-08-2012, 04:49 AM
  5. Insert Date Macro not correct
    By mikeal_s in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-12-2010, 12:44 AM

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