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,531
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,078,516
Messages
5,340,873
Members
399,396
Latest member
PBE

Some videos you may like

This Week's Hot Topics

  • Problem with Radio Button's format control
    I am creating an employee evaluation template (a sample is below) Column A is the category Column B, C D, E and F will be ratings (unacceptable...
  • Last Display on userform to a Listbox
    [CODE=vba] lstdisplay.ColumnCount = 15 lstdisplay.RowSource = "A1:O600000" [/CODE] So when i do this it Displays everything on the sheet i am...
  • Rename and move files to a new location
    Dear all, I have an excel file with the following information. The actual file name is at column A but i want to rename it using the following...
  • Help with True/False Formula
    Hello! Am stumped how to fix this formula, in which my result returns 'True', but it should return False. =IF(AG2=True...
  • Clear extra characters from a provided range of cells
    Dear All, I have following code which gives me desired output to remove extra characters from a provided range. But it takes too much time when...
  • Help with Current and highest streaks
    Hi there, I've just joined the forum and this is my first post. I've already spent quite a bit of time searching the net and this forum for a...
Top