Salim Ahmed
Salim Ahmed

Reputation: 15

How to add timestamp and username to a column?

I have a module in Excel that highlights the row a specific color.

Sub RECEIVED()
    Application.ScreenUpdating = False
  
    ' Clear the color of all the cells
    ' ActiveSheet.Cells.Interior.ColorIndex = 0
 
    With ActiveCell
        ' Highlight the entire row and column that contain the active cell
        .EntireRow.Interior.ColorIndex = 50
        '.EntireColumn.Interior.ColorIndex = 41
    End With
    Application.ScreenUpdating = True
End Sub

I would like to add a date and time stamp as well as a username.
screengrab

The date and time stamp does not need to be in that format. I am fine with whatever works.

Upvotes: 0

Views: 88

Answers (1)

Tomasz
Tomasz

Reputation: 426

try this. i didnt test it but should work

Sub RECEIVED()
    Application.ScreenUpdating = False

    ' Clear the color of all the cells
    ' ActiveSheet.Cells.Interior.ColorIndex = 0

    With ActiveCell
        ' Highlight the entire row and column that contain the active cell
        .EntireRow.Interior.ColorIndex = 50
        '.EntireColumn.Interior.ColorIndex = 41
    End With 
    dim str_Text as string : str_Text = application.username & " " & now
    activesheet.range("J" & selection.row) =str_Text     ' ad info in column J
    Application.ScreenUpdating = True
End Sub

Upvotes: 1

Related Questions