Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Conditional Formatting the whole column

Is it possible to apply Conditional Formatting to cells in
a column, each with there own formula.

dog 1 2
cat 2 5
cow 5 3
rat 13 1

I would like to highlight each cell in the first column
red or blue depending on which of the two number columns
is greater.
Red if the 3rd column is greater and blue is the second
column is greater.

Results:

dog - blue
cat - blue
cow - red
rat - red

Thank you for any help.


Simon


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Conditional Formatting the whole column

Hello Simon

Press ALT F11, Insert Module and paste the following code.

Sub CondFormat()
Dim n As Integer
Cells(2, 1).Select
n = ActiveCell.CurrentRegion.Rows.Count

For i = 2 To n
Cells(i, 1).Select
If ActiveCell.Offset(0, 1) = ActiveCell.Offset(0, 2) Then
ActiveCell.Interior.ColorIndex = xlNone
ElseIf ActiveCell.Offset(0, 1).Value ActiveCell.Offset
(0, 2) Then
ActiveCell.Interior.ColorIndex = 3
Else: ActiveCell.Interior.ColorIndex = 41
End If
Next i

End Sub

This produces the results that you showed in the example,
change the index values if you want to swap them.

It also leaves the formatting blank if column 3 and column
2 values are the same. Delete this line if you do not want
this and change the ElseIf to If

Run the Macro from the Tools, Macro, Run menu in Excel.

Regards
Peter
-----Original Message-----
Is it possible to apply Conditional Formatting to cells

in
a column, each with there own formula.

dog 1 2
cat 2 5
cow 5 3
rat 13 1

I would like to highlight each cell in the first column
red or blue depending on which of the two number columns
is greater.
Red if the 3rd column is greater and blue is the second
column is greater.

Results:

dog - blue
cat - blue
cow - red
rat - red

Thank you for any help.


Simon


.

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
have B column turn red on conditional formatting of E column: jsharper Excel Worksheet Functions 2 September 7th 09 10:42 PM
Conditional Formatting A Whole Column varsityfresh Excel Discussion (Misc queries) 1 December 10th 08 12:01 AM
Formatting cells in a column with conditional formatting? shamor Excel Discussion (Misc queries) 8 May 19th 08 10:11 PM
Column conditional formatting Rhys'''' Pieces Excel Discussion (Misc queries) 2 April 10th 06 04:25 PM
column to column conditional formatting won't work, need formula rrupp Excel Worksheet Functions 1 August 23rd 05 10:06 PM


All times are GMT +1. The time now is 11:57 PM.

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"