+ Reply to Thread
Results 1 to 10 of 10

Adding a time Macro

  1. #1
    Registered User
    Join Date
    03-12-2016
    Location
    Harare Zimbabwe
    MS-Off Ver
    2013
    Posts
    82

    Adding a time Macro

    Greetings

    I am developing a call log data base in Excel 2013, I would like to add a time each time a task is completed. There are several lines in the call log and each time the task is completed I would like to click on a button for that line that will record the date and time the task was completed. I know how to do a macro but not sure how to add the date and time

    Many thanks

    Rodney

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,897

    Re: Adding a time Macro

    Put a button on your worksheet. Link this code to the button.

    Please Login or Register  to view this content.
    When you press the button, this macro will put the time and date in what ever cell is active
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    03-12-2016
    Location
    Harare Zimbabwe
    MS-Off Ver
    2013
    Posts
    82

    Re: Adding a time Macro

    Quote Originally Posted by alansidman View Post
    Put a button on your worksheet. Link this code to the button.

    Please Login or Register  to view this content.
    When you press the button, this macro will put the time and date in what ever cell is active
    Please excuse my ignorance but how do I link the code to the button

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,897

    Re: Adding a time Macro

    On the developer tab.
    1. Click on Design Mode
    2. Insert, select form controls and select a command button
    3. Click on the button
    4. Assign Macro
    5. Select your macro
    6. Click on design mode to close this mode


    https://support.office.com/en-us/art...d-9c72c843a283

  5. #5
    Registered User
    Join Date
    03-12-2016
    Location
    Harare Zimbabwe
    MS-Off Ver
    2013
    Posts
    82

    Re: Adding a time Macro

    Quote Originally Posted by alansidman View Post
    On the developer tab.
    1. Click on Design Mode
    2. Insert, select form controls and select a command button
    3. Click on the button
    4. Assign Macro
    5. Select your macro
    6. Click on design mode to close this mode


    https://support.office.com/en-us/art...d-9c72c843a283
    Thank you I have added the button but now do not know how to add this script

    Option Explicit

    Sub Log()
    ActiveCell = Now
    End Sub

    Normally I record a macro so I can do that I have never had to add a script so have no idea how to do that

  6. #6
    Registered User
    Join Date
    03-12-2016
    Location
    Harare Zimbabwe
    MS-Off Ver
    2013
    Posts
    82

    Re: Adding a time Macro

    Hi

    Thank you for the help and your advice "Google is your friend" I have managed to link the code to the macro button after I adde the VBA code by following these instructions.

    https://www.ablebits.com/office-addi...a-macro-excel/

    I just want to add seconds now to the date and time. How do I do that

    Many thanks

  7. #7
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,897

    Re: Adding a time Macro

    use the format Icon on the ribbon and go to Date and make your selection

  8. #8
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Adding a time Macro

    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  9. #9
    Registered User
    Join Date
    03-12-2016
    Location
    Harare Zimbabwe
    MS-Off Ver
    2013
    Posts
    82

    Re: Adding a time Macro

    Quote Originally Posted by bakerman2 View Post
    Please Login or Register  to view this content.
    Thank you for this, I however still do not see the seconds. The column is formatted as general . Not sure what to do now

  10. #10
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Adding a time Macro

    Did you try to format the column as Custom dd/mm/yyyy hh:mm:ss ?

+ 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] Adding / Subtracting TIME VAULES / UNITS (Not time of Day) - I'm lost ... [RESOLVED]
    By BaLLZaCH in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-21-2015, 10:02 PM
  2. Adding a Subroutine to my macro for slowing down time
    By b_rianv in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-10-2014, 05:03 PM
  3. [SOLVED] time line adding a specific time frame in each additional cell
    By RobertM01 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 06-23-2014, 10:22 AM
  4. adding days/hours automatically to date time using a macro
    By dexter87 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-11-2011, 08:26 PM
  5. Adding Date and Time - Running the Macro
    By Shark Man in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-13-2009, 01:33 PM
  6. Adding Time: Adding individual cells works, but SUM doesn't
    By fredmeister in forum Excel General
    Replies: 17
    Last Post: 04-11-2008, 10:40 AM
  7. Still adding to Complex Macro...1 step at a time.
    By oberon.black in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-04-2005, 01:05 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