ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Conditional Formatting (https://www.excelbanter.com/excel-worksheet-functions/149067-conditional-formatting.html)

Melanie

Conditional Formatting
 
I need to format 5 conditions in a particular spreadsheet. I can add the 4th
by using the fill option over the area but having problems adding the 5th.
Any ideas? Thanks.

Mike H

Conditional Formatting
 
Melanie,

You can have an unlimited amount with the worksheet_change event and select
case.

Right click your sheet tab|view code and paste this in:-

Private Sub Worksheet_Change(ByVal Target As Range)
Dim colour As Integer

If Not Intersect(Target, Range("A1:A100")) Is Nothing Then
Select Case Target
Case 1
colour = 6
Case 2
colour = 12
Case 3
colour = 7
Case 4
colour = 53
Case 5
colour = 15
Case 6
colour = 42
Case Else
'do nothing
End Select

Target.Interior.ColorIndex = colour
End If

End Sub

Alter what thecase is to suit for example
Case Is = "some text"

or

Case Is 99

Mike




"Melanie" wrote:

I need to format 5 conditions in a particular spreadsheet. I can add the 4th
by using the fill option over the area but having problems adding the 5th.
Any ideas? Thanks.


Melanie

Conditional Formatting
 
Thanks Mike, a great help.

Melanie

"Mike H" wrote:

Melanie,

You can have an unlimited amount with the worksheet_change event and select
case.

Right click your sheet tab|view code and paste this in:-

Private Sub Worksheet_Change(ByVal Target As Range)
Dim colour As Integer

If Not Intersect(Target, Range("A1:A100")) Is Nothing Then
Select Case Target
Case 1
colour = 6
Case 2
colour = 12
Case 3
colour = 7
Case 4
colour = 53
Case 5
colour = 15
Case 6
colour = 42
Case Else
'do nothing
End Select

Target.Interior.ColorIndex = colour
End If

End Sub

Alter what thecase is to suit for example
Case Is = "some text"

or

Case Is 99

Mike




"Melanie" wrote:

I need to format 5 conditions in a particular spreadsheet. I can add the 4th
by using the fill option over the area but having problems adding the 5th.
Any ideas? Thanks.



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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com