Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default VBA change font color if existing cell value changes

Hi,

I have found a macro on the net and edited so that if an exisiting
cell value is changed the font will change to red.
However, I am trying to amend this code so that it refers to an entire
column and not just a cell. I am very new to VB and have not found a
way. Can someone help me amend this code or know a better way of doing
this.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = ("$A$2") Then
Range("A2").Font.Color = RGB(255, 0, 0)
End If
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default VBA change font color if existing cell value changes

You didn't tells, so assuming the column you want to change is Column A...

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$2" Then
Range("A2").EntireColumn.Font.Color = RGB(255, 0, 0)
End If
End Sub

--
Rick (MVP - Excel)


wrote in message
...
Hi,

I have found a macro on the net and edited so that if an exisiting
cell value is changed the font will change to red.
However, I am trying to amend this code so that it refers to an entire
column and not just a cell. I am very new to VB and have not found a
way. Can someone help me amend this code or know a better way of doing
this.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = ("$A$2") Then
Range("A2").Font.Color = RGB(255, 0, 0)
End If
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default VBA change font color if existing cell value changes

On Jan 30, 6:47*pm, "Rick Rothstein"
wrote:
You didn't tells, so assuming the column you want to change is Column A....

Private Sub Worksheet_Change(ByVal Target As Range)
* * If Target.Address = "$A$2" Then
* * * * Range("A2").EntireColumn.Font.Color = RGB(255, 0, 0)
* * End If
End Sub

--
Rick (MVP - Excel)

wrote in message

...

Hi,


I have found a macro on the net and edited so that if an exisiting
cell value is changed the font will change to red.
However, I am trying to amend this code so that it refers to an entire
column and not just a cell. I am very new to VB and have not found a
way. Can someone help me amend this code or know a better way of doing
this.


Private Sub Worksheet_Change(ByVal Target As Range)
* *If Target.Address = ("$A$2") Then
* * * *Range("A2").Font.Color = RGB(255, 0, 0)
* *End If
End Sub


Hi Rick,

My column is A.
However, I am not sure if this adjustment is doing what it needs to.
My range is in column A (not just A2) and if any cell is changed in A
then I need the cell to change the font colour.
Is there a way to do this?

Thanks!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default VBA change font color if existing cell value changes

The Range("A2").EntireColumn properties returns a range referring to the
whole column containing A2, that means olumn A

" wrote:

On Jan 30, 6:47 pm, "Rick Rothstein"
wrote:
You didn't tells, so assuming the column you want to change is Column A....

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$2" Then
Range("A2").EntireColumn.Font.Color = RGB(255, 0, 0)
End If
End Sub

--
Rick (MVP - Excel)

wrote in message

...

Hi,


I have found a macro on the net and edited so that if an exisiting
cell value is changed the font will change to red.
However, I am trying to amend this code so that it refers to an entire
column and not just a cell. I am very new to VB and have not found a
way. Can someone help me amend this code or know a better way of doing
this.


Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = ("$A$2") Then
Range("A2").Font.Color = RGB(255, 0, 0)
End If
End Sub


Hi Rick,

My column is A.
However, I am not sure if this adjustment is doing what it needs to.
My range is in column A (not just A2) and if any cell is changed in A
then I need the cell to change the font colour.
Is there a way to do this?

Thanks!

  #5   Report Post  
Posted to microsoft.public.excel.programming
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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot change font color or cell color Bezell Excel Discussion (Misc queries) 2 January 30th 09 06:12 PM
change font color depending on cell value Mickey Excel Worksheet Functions 12 October 1st 08 01:41 AM
Reg. Change of font color in a cell Ravi Excel Worksheet Functions 1 June 27th 08 10:07 AM
Change font color in cell Peggy Excel Discussion (Misc queries) 2 June 24th 08 04:30 PM
How to change the default Border, Font Color, and Cell Color Elijah Excel Discussion (Misc queries) 3 November 2nd 05 11:52 PM


All times are GMT +1. The time now is 07:42 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"