+ Reply to Thread
Results 1 to 7 of 7

writing a macro to convert date time in a sheet

  1. #1
    Registered User
    Join Date
    02-14-2012
    Location
    Ottawa
    MS-Off Ver
    Excel 2010
    Posts
    6

    writing a macro to convert date time in a sheet

    Hi all, I will try to make my question easily understood (which actually means I understand what I am asking )
    I have a spread sheet with a list of open tickets that were exported. Say rows 2 - 50. Column G shows open time. (row 1 is a header)
    Column H from above shows update time.
    I then export a list of closed tickets and tack that on the bottom of the open cases. Say rows 51-70 Column I shows closed time. Closed time is column I.

    My question is this (being new to macros) I want to insert a blank column to the right of G and put in this formula in that blank column to the right of my date time column G above =g2-(9.5/24) and have that same reference formula copy from 1-50.(the # of cases is not always the same 50 today could be 70 tomorrow or 35)

    I would do the exact same steps for column H above =h2-(9.5/24)

    Next step is to do the same for Column I but not sure how I get the focus on row 51 (since first 50 rows are blank as they are not closed) and again goto bottom of the data (with varying amounts each time it is run) and paste that same formula.). This is where I have a problem as I do not know what row my closed data starts on =I??-(9.5/24) - is there a way to say go to first item in this column and move to right and paste formula?

    Now I will copy (what is temp column H) and PASTE VALUES only to col G and delete col H
    once that is deleted
    I will copy (what is temp column I) and PASTE VALUES only to col H and delete col I
    and finally do the same for column I ...

    I hope that all makes sense and someone can help me with my questions ... interesting stuff but not familiar enough with all the commands
    same on

  2. #2
    Registered User
    Join Date
    04-25-2009
    Location
    Los Angeles
    MS-Off Ver
    Excel 2010
    Posts
    84

    Re: writing a macro to convert date time in a sheet

    please attached a sample file that simulates the data and the desire result. it would help a lot.

  3. #3
    Registered User
    Join Date
    02-14-2012
    Location
    Ottawa
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: writing a macro to convert date time in a sheet

    OK not sure what I am doing wrong but I do not have the ability, using normal and advanced modes, to be able to attach a picture or a file.

    I have created a snippet from the original file so you can see it exactly. I have changed the data so as not to expose ... the 3 columns I am interested in are G H I
    as these are the date time columns.

    I am going to try and paste a link in here ... I will upload the files (graphic and xlsx) to my ftp space and post the link in a few mins

  4. #4
    Registered User
    Join Date
    02-14-2012
    Location
    Ottawa
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: writing a macro to convert date time in a sheet


  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: writing a macro to convert date time in a sheet

    Hello bz6djs,

    As I understand your first post, the date/time values in columns "G:I", starting in row 2 down to the last row with data, need to have 9.5 hours subtracted from the cell if it is not empty. If this correct then the following macro will work. It has been added to the attached workbook.

    To run the macro you can use the keys Alt+F8 to display the Macro Dialog. Click on UpdateDateAndTime and then click Run.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  6. #6
    Registered User
    Join Date
    02-14-2012
    Location
    Ottawa
    MS-Off Ver
    Excel 2010
    Posts
    6

    Thumbs up Re: writing a macro to convert date time in a sheet

    Please disregard my last post ... now that I have re-read what was written and tested it ... THIS IS PERFECT!! Thank You So Much!

  7. #7
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: writing a macro to convert date time in a sheet

    Hello bz6djs,

    You're welcome. I am going to mark this post as solved.

+ 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. help for writing a code to sort time and date column
    By mili66 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-14-2015, 08:27 AM
  2. [SOLVED] Convert Unix Date-time stamp to excel date and/or time columns
    By judikz in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-13-2015, 05:46 PM
  3. [SOLVED] VBA macro about writing time on rows and single cell at same time
    By Roger1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-01-2015, 12:17 PM
  4. Convert Julian date/ time to regular date/ time (MM/DD/YYYY HH:MM:SS)
    By dataguy30 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-07-2013, 11:33 AM
  5. [SOLVED] How do I convert imported date/time data to date/time format?
    By andykent99 in forum Excel General
    Replies: 4
    Last Post: 01-03-2013, 07:47 AM
  6. Convert Julian Date/Time (ddd.tttttt) to Calendar Date/Time
    By LindseyW in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-12-2009, 09:30 PM
  7. Writing update date and time in a cell on inputs
    By a94andwi in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-17-2006, 09:45 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