Excel Macro for Text + Today's Date/time

Anonymous
2020-09-25T20:46:48+00:00

I need a macro button when pressed will enter into the active cell a static text string as well as the current date and time for example DVC20200925164622. The result needs to stay as it is, not update afterwards.

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes
Answer accepted by question author
  1. Anonymous
    2020-09-25T20:55:18+00:00

    Hi Brian

    Here is your macro

    *******************************************************

    Sub TextPlusTimeStamp()

    ActiveCell.Value = "DVC" & Format(Now, "yyyymmddhhnnss")

    End Sub

    *************************************************************

    I hope this helps you and gives a solution to your problem

    Regards

    Jeovany

    1 person found this answer helpful.
    0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  2. Anonymous
    2020-09-25T21:16:14+00:00

    Thanks very much Jeovany! It works perfectly. I appreciate it. Brian

    0 comments No comments
  3. Anonymous
    2020-09-25T22:16:44+00:00

    Hi Brian_Del,

    Thanks for reaching out. My name is Ali. I'm an Independent Advisor and a Microsoft user like you. I'll be happy to help you out today.

    Please use the shortcut Alt + F11 to open the VBA window and put the below code and then assign the button to this code.

    Please refer to the link below that how you can link your existing code with a button in excel.

    https://trumpexcel.com/assign-macro-to-button-i...

    Note: This is a non-Microsoft website. The page appears to be providing accurate, safe information. Watch out for ads on the site that may advertise products frequently classified as a PUP (Potentially Unwanted Products). Thoroughly research any product advertised on the site before you decide to download and install it.


    Sub textdatetime()

    Dim ts As Date

    With Selection

    .Value = "DVC" & WorksheetFunction.Text(Now, "yyyymmddhhmmss")

    End With

    End Sub


    At the end do save this file as .xlsm extension to work with this code in future.

    I hope it worked out well for you. If not, please reply back to this forum to let me know or mark this as resolved along with your feedback. :) I will be glad to follow up and help you.

    Thanks,

    Ali

    0 comments No comments