Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Ayo Ayo is offline
external usenet poster
 
Posts: 489
Default Conditional Formatting using code

I am trying to write a contionalformat in code. I have this code ight now:
Range("E1:E10").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreater, _
Formula1:="0"
With Selection.FormatConditions(1).Font
.Bold = True
.Italic = False
.ColorIndex = 3
End With

This is not doing what I need. I want a code that would change the font
color in a range of cells based on if the value of another cell is equal to
zero. How do I go about doing this.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,942
Default Conditional Formatting using code

hi
set up a true/false condition in the CF cell base on the target cell.
such as if other cell = 0 then true else false
or
=if(b1=0,1,0)

Sub AddCF()
Dim r As Range
Set r = Range("C1") '<--change to suit

r.FormatConditions.Delete
r.FormatConditions.Add _
Type:=xlExpression, Formula1:= _
"=IF(B1=0,1,0)" '<--change to suit
With r.FormatConditions(1).Font
.Bold = True
.Italic = False
.ColorIndex = 3
End With
End Sub

regards
FSt1

"Ayo" wrote:

I am trying to write a contionalformat in code. I have this code ight now:
Range("E1:E10").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreater, _
Formula1:="0"
With Selection.FormatConditions(1).Font
.Bold = True
.Italic = False
.ColorIndex = 3
End With

This is not doing what I need. I want a code that would change the font
color in a range of cells based on if the value of another cell is equal to
zero. How do I go about doing this.

  #3   Report Post  
Posted to microsoft.public.excel.misc
Ayo Ayo is offline
external usenet poster
 
Posts: 489
Default Conditional Formatting using code

Thank you somuch FSt1.

"FSt1" wrote:

hi
set up a true/false condition in the CF cell base on the target cell.
such as if other cell = 0 then true else false
or
=if(b1=0,1,0)

Sub AddCF()
Dim r As Range
Set r = Range("C1") '<--change to suit

r.FormatConditions.Delete
r.FormatConditions.Add _
Type:=xlExpression, Formula1:= _
"=IF(B1=0,1,0)" '<--change to suit
With r.FormatConditions(1).Font
.Bold = True
.Italic = False
.ColorIndex = 3
End With
End Sub

regards
FSt1

"Ayo" wrote:

I am trying to write a contionalformat in code. I have this code ight now:
Range("E1:E10").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreater, _
Formula1:="0"
With Selection.FormatConditions(1).Font
.Bold = True
.Italic = False
.ColorIndex = 3
End With

This is not doing what I need. I want a code that would change the font
color in a range of cells based on if the value of another cell is equal to
zero. How do I go about doing this.

  #4   Report Post  
Posted to microsoft.public.excel.misc
Ayo Ayo is offline
external usenet poster
 
Posts: 489
Default Conditional Formatting using code

It is not working quite right. This is what I have:

Dim r As Range
Set r = Range("E1:E10") '<--change to suit

r.FormatConditions.Delete
r.FormatConditions.Add _
Type:=xlExpression, Formula1:="=IF(A1=0,1,0)" '<--change to suit
With r.FormatConditions(1).Font
.Bold = True
.Italic = False
.ColorIndex = 3
End With

Whan I enter 0 or 1 in cell A1 the font in the range still changes. I only
want it to change when A1 is zero.

"FSt1" wrote:

hi
set up a true/false condition in the CF cell base on the target cell.
such as if other cell = 0 then true else false
or
=if(b1=0,1,0)

Sub AddCF()
Dim r As Range
Set r = Range("C1") '<--change to suit

r.FormatConditions.Delete
r.FormatConditions.Add _
Type:=xlExpression, Formula1:= _
"=IF(B1=0,1,0)" '<--change to suit
With r.FormatConditions(1).Font
.Bold = True
.Italic = False
.ColorIndex = 3
End With
End Sub

regards
FSt1

"Ayo" wrote:

I am trying to write a contionalformat in code. I have this code ight now:
Range("E1:E10").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreater, _
Formula1:="0"
With Selection.FormatConditions(1).Font
.Bold = True
.Italic = False
.ColorIndex = 3
End With

This is not doing what I need. I want a code that would change the font
color in a range of cells based on if the value of another cell is equal to
zero. How do I go about doing this.

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 419
Default Conditional Formatting using code

Ayo,

How about this:

Dim r As Range
Set r = Range("E1:E10") '<--change to suit

r.FormatConditions.Delete
r.FormatConditions.Add _
Type:=xlExpression, Formula1:="=A1=0" '<--change to suit
With r.FormatConditions(1).Font
.Bold = True
.Italic = False
.ColorIndex = 3
End With

HTH,

Conan






"Ayo" wrote in message
...
It is not working quite right. This is what I have:

Dim r As Range
Set r = Range("E1:E10") '<--change to suit

r.FormatConditions.Delete
r.FormatConditions.Add _
Type:=xlExpression, Formula1:="=IF(A1=0,1,0)" '<--change to
suit
With r.FormatConditions(1).Font
.Bold = True
.Italic = False
.ColorIndex = 3
End With

Whan I enter 0 or 1 in cell A1 the font in the range still changes. I only
want it to change when A1 is zero.

"FSt1" wrote:

hi
set up a true/false condition in the CF cell base on the target cell.
such as if other cell = 0 then true else false
or
=if(b1=0,1,0)

Sub AddCF()
Dim r As Range
Set r = Range("C1") '<--change to suit

r.FormatConditions.Delete
r.FormatConditions.Add _
Type:=xlExpression, Formula1:= _
"=IF(B1=0,1,0)" '<--change to suit
With r.FormatConditions(1).Font
.Bold = True
.Italic = False
.ColorIndex = 3
End With
End Sub

regards
FSt1

"Ayo" wrote:

I am trying to write a contionalformat in code. I have this code ight
now:
Range("E1:E10").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlCellValue,
Operator:=xlGreater, _
Formula1:="0"
With Selection.FormatConditions(1).Font
.Bold = True
.Italic = False
.ColorIndex = 3
End With

This is not doing what I need. I want a code that would change the
font
color in a range of cells based on if the value of another cell is
equal to
zero. How do I go about doing this.





  #6   Report Post  
Posted to microsoft.public.excel.misc
Ayo Ayo is offline
external usenet poster
 
Posts: 489
Default Conditional Formatting using code

Same thing.

"Conan Kelly" wrote:

Ayo,

How about this:

Dim r As Range
Set r = Range("E1:E10") '<--change to suit

r.FormatConditions.Delete
r.FormatConditions.Add _
Type:=xlExpression, Formula1:="=A1=0" '<--change to suit
With r.FormatConditions(1).Font
.Bold = True
.Italic = False
.ColorIndex = 3
End With

HTH,

Conan






"Ayo" wrote in message
...
It is not working quite right. This is what I have:

Dim r As Range
Set r = Range("E1:E10") '<--change to suit

r.FormatConditions.Delete
r.FormatConditions.Add _
Type:=xlExpression, Formula1:="=IF(A1=0,1,0)" '<--change to
suit
With r.FormatConditions(1).Font
.Bold = True
.Italic = False
.ColorIndex = 3
End With

Whan I enter 0 or 1 in cell A1 the font in the range still changes. I only
want it to change when A1 is zero.

"FSt1" wrote:

hi
set up a true/false condition in the CF cell base on the target cell.
such as if other cell = 0 then true else false
or
=if(b1=0,1,0)

Sub AddCF()
Dim r As Range
Set r = Range("C1") '<--change to suit

r.FormatConditions.Delete
r.FormatConditions.Add _
Type:=xlExpression, Formula1:= _
"=IF(B1=0,1,0)" '<--change to suit
With r.FormatConditions(1).Font
.Bold = True
.Italic = False
.ColorIndex = 3
End With
End Sub

regards
FSt1

"Ayo" wrote:

I am trying to write a contionalformat in code. I have this code ight
now:
Range("E1:E10").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlCellValue,
Operator:=xlGreater, _
Formula1:="0"
With Selection.FormatConditions(1).Font
.Bold = True
.Italic = False
.ColorIndex = 3
End With

This is not doing what I need. I want a code that would change the
font
color in a range of cells based on if the value of another cell is
equal to
zero. How do I go about doing this.




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
Conditional Formatting - Code to colour 3+ text values differently AK9955 Excel Discussion (Misc queries) 3 November 9th 09 06:11 PM
Protect Cell Formatting including Conditional Formatting Mick Jennings Excel Discussion (Misc queries) 5 November 13th 07 05:32 PM
conditional formatting w/ more than 3 conditionas, color code to a different cell oldbarnes About this forum 0 May 24th 07 01:27 AM
Override conditional formatting with code Sarah Excel Discussion (Misc queries) 4 April 30th 07 08:28 PM
Macro code to delete conditional formatting Bovine Jones Excel Discussion (Misc queries) 5 October 19th 06 08:39 AM


All times are GMT +1. The time now is 02:55 PM.

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

About Us

"It's about Microsoft Excel"