+ Reply to Thread
Results 1 to 15 of 15

Add Time & Date in current cell without losing existing data

  1. #1
    Forum Contributor
    Join Date
    10-14-2007
    MS-Off Ver
    Excel 2021
    Posts
    121

    Add Time & Date in current cell without losing existing data

    Trying to create a macro that will add the date & time & initials (i.e 8/26/09 2:34 PM JOD) into the current cell.

    I've found plenty of macro's that will do this but it ends up deleting any existing text within the cell. I need to be able to add it in the middle of a text string.

    Any help would be greatly appreciated

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Add Time & Date in current cell without losing existing data

    For example, ...
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Contributor
    Join Date
    10-14-2007
    MS-Off Ver
    Excel 2021
    Posts
    121

    Re: Add Time & Date in current cell without losing existing data

    For example, the following macro will insert Date/Time into a field but it clears the contents of anything in the cell.

    Sub Set_DateTime()
    ActiveCell.Value = Format(Now(), "m/dd/yyyy h:mmAM/PM")
    End Sub

    This is an example of what my notes field would look like:
    8/26/09 2:33 PM JOC Tested Ok. 8/27/09 3:33 PM ABC Sent tech to regional.

    How can i automatically add 8/27/09 3:33 PM ABC without clearing the existing data in the cell?

    Thanks

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Add Time & Date in current cell without losing existing data

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    10-14-2007
    MS-Off Ver
    Excel 2021
    Posts
    121

    Re: Add Time & Date in current cell without losing existing data

    Sorry for not putting the macro within a code. Still no luck with this one?

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Add Time & Date in current cell without losing existing data

    Pardon?

    Try the code I posted.

  7. #7
    Forum Contributor
    Join Date
    10-14-2007
    MS-Off Ver
    Excel 2021
    Posts
    121

    Re: Add Time & Date in current cell without losing existing data

    Thanks SHG for your help!

    The only problem is that when i'm within the contents of the cell (i.e. You can see your cursor blinking within the cell), i'm unable to run the macro . If i only have the cell selected it will add it to the end of the line of text.

    Is there anyway to get around this so i can add the datestamp wherever my cursor is at within the string of text?

    Thanks again
    Impala096

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Add Time & Date in current cell without losing existing data

    Nope. Short of doing stuff with Windows API, when Excel is in Edit mode, VBA is locked out.

  9. #9
    Forum Contributor
    Join Date
    10-14-2007
    MS-Off Ver
    Excel 2021
    Posts
    121

    Re: Add Time & Date in current cell without losing existing data

    Ok, thanks again SHG!

  10. #10
    Forum Contributor
    Join Date
    10-14-2007
    MS-Off Ver
    Excel 2021
    Posts
    121

    Re: Add Time & Date in current cell without losing existing data

    One more simple problem i just can't figure out. The timestamp is also going to include the initials of the person that is entering the data. I slightly modified your code to look like this.

    Please Login or Register  to view this content.
    I expected it to return a result like 9/1/09@13:32 TJC.... it returned 9/1/09@13:32 TJ9/1/2009 2:34:21 PM.

    The letters T & J appeared as expected.. C didn't appear correctly at all.

  11. #11
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Add Time & Date in current cell without losing existing data

    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    04-11-2013
    Location
    Boston, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Add Time & Date in current cell without losing existing data

    Hello,

    I realize this is a fairly old post, but can anyone tell me how to how add this same stamp to the beginning of the cell instead of the end, while still retaining the original text? In addition, is it possible to make this specific text bold?

    I am using Excel 2010 for Windows.

    Thanks!

  13. #13
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Add Time & Date in current cell without losing existing data

    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    04-11-2013
    Location
    Boston, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Add Time & Date in current cell without losing existing data

    Thank you shg! One issue I'm having is that when you enter this time stamp, it unbolds all previous stamps in the cell. Is it possible to not affect the pre-existing text format? Also, is it possible to push the old text down to the line below the new stamp, something similar to what I've pasted below? I have also included what my code currently looks like.

    "05/19/2014 (SM): Allocated.
    05/18/2014 (SM): Uploaded."


    Please Login or Register  to view this content.

  15. #15
    Registered User
    Join Date
    05-21-2014
    Posts
    1

    Re: Add Time & Date in current cell without losing existing data

    Thanks you so much!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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