How to change text to red if value in cell changes and add last updated on date to the row

JSH720

Board Regular
Joined
Oct 9, 2009
Messages
96
I need to change the cell text format to RED if the value of the cell is changed (not formatting or just clicking in it). Additionall, when the cell is changed in a row, a column at the end needs to show the date last changed (mm/dd/yyyy) and name of computer that changedit.

Is this accomplished with conditional formatting or VBA?

How do you do it?

Thanks!
 

Misca

Well-known Member
Joined
Aug 12, 2009
Messages
1,558
Paste the following to the worksheet module:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)

Dim CN As String


With Application
    .EnableEvents = False   'if this was left true the macro would trigger itself
    .ScreenUpdating = False
End With


CN = Environ("computername")  'Environ("username") would return the current user name


If Target.Cells.Count > 1 Then  'Remove or comment these rows if it doesn't matter how many cells are changed at the same time
    GoTo TheEnd 'Jumps to the end without making the changes
End If


    With Target
        .Font.ColorIndex = 3
'        Intersect(.EntireRow, Range("Z:Z")).Value = Format(Date, "mm/dd/yyyy") & " " & CN   'Always the same column
        Cells(.Row, Columns.Count).End(xlToLeft).Offset(, 1).Value = Format(Date, "mm/dd/yyyy") & " " & CN  'Alwasy the last column
    End With




TheEnd:


With Application
    .EnableEvents = True
    .ScreenUpdating = True
End With


End Sub
 

Forum statistics

Threads
1,084,850
Messages
5,380,276
Members
401,660
Latest member
Zakariyya Ibrahim

Some videos you may like

This Week's Hot Topics

Top