conditional formatting
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

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

Conditional Formatting

resolvedResolved · Urgent Priority · Version 2003

replyReply Sun 8 Jun 2008, 17:20Delegate Lisa said...

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?

For upcoming training course dates see: Pricing & availability

replyReply Sun 8 Jun 2008, 23:42Trainer Katie said...

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

 

Please browse our web site to find out more about
excel+course and other Microsoft training courses.

Excel tip:

Sorting data stored in rows

Primarily Excel is set up to sort data that is stored in columns rather than rows.

It is possible to get Excel to sort data stored in rows however.

Click in the row you want to sort, or select the cells in the rows you wish to sort.

Go to Data - Sort, then go to the Options button in the bottom left corner of the Sort dialogue box.

View all Excel hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard