View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Wisdomandlaughter Wisdomandlaughter is offline
external usenet poster
 
Posts: 1
Default VBA change font color if existing cell value changes

Eric,

I am searching for a code that will do exactly what the code you posted will
do but for a range of columns rather than one column. Currently the columns
being used are A:N. Is it possible to tweak the code you provided to do
this?

Thank you much.

Judy

"egun" wrote:

Insert this code into the worksheet in which you want to change the font
color. Select the column you want to monitor, and then try making some
changes to cells in that column.

HTH,

Eric

Option Explicit

'
' This routine will change the font color of any
' cell in the chose column on the active worksheet
' to a different color if that cell is changed.
'
Private Sub Worksheet_Change(ByVal Target As Range)
Dim theCell As Range
Dim theArea As Range
Dim theColumn As Integer
'
theColumn = 1 ' Column "A" == set to desired column
'
For Each theArea In Target.Areas ' Can have multiple areas selected...
For Each theCell In theArea.Cells
If (theCell.Column = theColumn) Then ' Only cells in chosen
column...
theCell.Font.ColorIndex = 3 ' Set to red, or other color
End If
Next theCell
Next theArea
End Sub