excel concatenate text to date time stamp

Taras
Taras used Ask the Experts™
on
I am using this code to put time stamp in cell B5:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCells As Range

    ' The variable KeyCells contains the cells that will
    ' cause an alert when they are changed.

    With Me
        Set KeyCells = .Range("D5")
   
        If Not Application.Intersect(KeyCells, Target) Is Nothing Then
   
            ' we will put time stamp in cell B5
            Application.EnableEvents = False
            .Cells(5, "B").Value = Now()
            .Cells(5, "B").NumberFormat = "m/d/yyyy h:mm AM/PM"
            Application.EnableEvents = True
        End If

    End With

End Sub

It works ok however I need to concatenate  "Run at: "  to this time stamp.
Any idea.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Mechanical Engineer
Most Valuable Expert 2013
Top Expert 2013
Commented:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCells As Range

    ' The variable KeyCells contains the cells that will
    ' cause an alert when they are changed.

    With Me
        If ActiveSheet.Name = Me.Name Then
             Set KeyCells = .Range("D5")
        
             If Not Application.Intersect(KeyCells, Target) Is Nothing Then
        
                 ' we will put time stamp in cell B5
                 Application.EnableEvents = False
                 .Cells(5, "B").Value = "Run at: " & Format(Now(), "m/d/yyyy h:mm AM/PM")
                 Application.EnableEvents = True
             End If
        End If

    End With

End Sub

Open in new window

Rob HensonFinance Analyst

Commented:
Replace the lines
 .Cells(5, "B").Value = Now()
 .Cells(5, "B").NumberFormat = "m/d/yyyy h:mm AM/PM"

Open in new window


With:
.Cells(5, "B").Value = "Run at: " & Format(Now(), "m/d/yyyy h:mm AM/PM")

Open in new window

Author

Commented:
Thank you a lot.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial