conditional formatting

Forum home » Delegate support and help forum » Microsoft Excel Training and help » Conditional Formatting

Conditional Formatting

resolvedResolved · Urgent Priority · Version 2003

Lisa has attended:
Excel VBA Intro Intermediate course

Conditional Formatting

With Conditional Formatting you can only get 3 conditions.

How do you get 5 conditions? - The following colours:-
Red
Orange
Yellow
Light Green
Dark Green

This would be starting in coloum E6 to E63?

RE: Conditional Formatting

Hi Lisa,

This scenario is slightly diffrent becuase of the fixed cell range (a fixed target), which means you can use the FOR structure. The previous scenario will wait for a new data entry to trigger the colour change.

Here is the sample codes:
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub ConditionalFormat()
Dim Counter As Integer
Dim Row As Integer 'The row being copied
Dim TotalRows As Integer 'Number of Colour Entries

Row = 2

Sheets("Sheet1").Select
Range("E6").Select

TotalRows = Range("E6").CurrentRegion.Rows.count
Debug.Print TotalRows

'Red
For Counter = 1 To TotalRows
If Cells(Row, 5).Value = "Red" Then
With Cells(Row, 5)
.Interior.ColorIndex = 3
.Font.Bold = True
.Font.ColorIndex = 3
End With

'Orange
ElseIf Cells(Row, 5).Value = "Orange" Then
With Cells(Row, 5)
.Interior.ColorIndex = 46
.Font.Bold = True
.Font.ColorIndex = 46
End With

'Yellow
ElseIf Cells(Row, 5).Value = "Yellow" Then
With Cells(Row, 5)
.Interior.ColorIndex = 6
.Font.Bold = True
.Font.ColorIndex = 6
End With

'Light Green
ElseIf Cells(Row, 5).Value = "Light Green" Then
With Cells(Row, 5)
.Interior.ColorIndex = 35
.Font.Bold = True
.Font.ColorIndex = 35
End With

'Dark Green
ElseIf Cells(Row, 5).Value = "Dark Green" Then
With Cells(Row, 5)
.Interior.ColorIndex = 10
.Font.Bold = True
.Font.ColorIndex = 10
End With
End If

Row = Row + 1 'Moves to next row after formatting
Next Counter


End Sub

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

See if this helps.

Katie
Microsoft Certified Trainer

 

Training courses

 

Training information:

See also:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Excel tip:

Removing custom dictionary entries

If you add something to the custom dictionary in Excel you cannot remove it. The way to get around this is to go into word and remove it there.

View all Excel hints and tips


Server loaded in 0.05 secs.