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

Does anyone know how i can format the background colour of
my cells dependent on their content. I can do this in
conditional formatting but only for 3 conditions and i
need about 20.

All i want is code that says

if cell content = fish - cell background = red
if cell content - animal - cell background = blue

etc.

Any one any ideas???
  #2   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Advanced Conditional Formatting

Add a control button then in code use a Case statement

Private Sub CommandButton1_Click()
Dim I As Integer
For I = 1 To 5
Cells(I, 1).Select
Select Case ActiveCell
Case "fish"
ActiveCell.Interior.ColorIndex = 30
Case "animal"
ActiveCell.Interior.ColorIndex = 40
Case Else
ActiveCell.Interior.ColorIndex = 0
End Select
Next

End Sub
-----Original Message-----
Does anyone know how i can format the background colour

of
my cells dependent on their content. I can do this in
conditional formatting but only for 3 conditions and i
need about 20.

All i want is code that says

if cell content = fish - cell background = red
if cell content - animal - cell background = blue

etc.

Any one any ideas???
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Advanced Conditional Formatting

I can't get this code to work properly. I have changed 1
to 5 to 50 so that it covers all my data and have also
coppied the Cells(I, 1).Select to reflect all of my
columns. The problem is is if I change the data and re-run
the macro it does not update the colours it just stays the
smae as the old colours.

Any ideas???

Danny

-----Original Message-----
Add a control button then in code use a Case statement

Private Sub CommandButton1_Click()
Dim I As Integer
For I = 1 To 5
Cells(I, 1).Select
Select Case ActiveCell
Case "fish"
ActiveCell.Interior.ColorIndex = 30
Case "animal"
ActiveCell.Interior.ColorIndex = 40
Case Else
ActiveCell.Interior.ColorIndex = 0
End Select
Next

End Sub
-----Original Message-----
Does anyone know how i can format the background colour

of
my cells dependent on their content. I can do this in
conditional formatting but only for 3 conditions and i
need about 20.

All i want is code that says

if cell content = fish - cell background = red
if cell content - animal - cell background = blue

etc.

Any one any ideas???
.

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 599
Default Advanced Conditional Formatting

Danny

You should use the Worksheet_Change event, in my opinion. Right click on
the sheet tab and choose View Code. The Paste this into code module.
Change as necessary.

Private Sub Worksheet_Change(ByVal Target As Range)

'Limits the range to which the formatting is applied
If Not Intersect(Target, Me.Range("a1:G10")) Is Nothing Then
Select Case Target.Value
Case "Fish"
Target.Interior.ColorIndex = 6
Case "Animal"
Target.Interior.ColorIndex = 3
'Add more case statements here if you nee them
Case Else
Target.Interior.ColorIndex = -4142
End Select
End If

End Sub

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.

"Danny" wrote in message
...
I can't get this code to work properly. I have changed 1
to 5 to 50 so that it covers all my data and have also
coppied the Cells(I, 1).Select to reflect all of my
columns. The problem is is if I change the data and re-run
the macro it does not update the colours it just stays the
smae as the old colours.

Any ideas???

Danny

-----Original Message-----
Add a control button then in code use a Case statement

Private Sub CommandButton1_Click()
Dim I As Integer
For I = 1 To 5
Cells(I, 1).Select
Select Case ActiveCell
Case "fish"
ActiveCell.Interior.ColorIndex = 30
Case "animal"
ActiveCell.Interior.ColorIndex = 40
Case Else
ActiveCell.Interior.ColorIndex = 0
End Select
Next

End Sub
-----Original Message-----
Does anyone know how i can format the background colour

of
my cells dependent on their content. I can do this in
conditional formatting but only for 3 conditions and i
need about 20.

All i want is code that says

if cell content = fish - cell background = red
if cell content - animal - cell background = blue

etc.

Any one any ideas???
.

.



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 sum - Two dimensional (advanced) StephenT Excel Discussion (Misc queries) 3 February 18th 10 02:15 PM
Advanced Conditional Formatting [email protected] Excel Worksheet Functions 8 September 22nd 08 01:33 PM
Advanced conditional formatting oli_qld Excel Discussion (Misc queries) 3 November 3rd 07 09:38 PM
Advanced Conditional Formatting Ideas Needed! (ok, maybe not that advanced...) shadestreet Excel Discussion (Misc queries) 2 July 21st 06 03:04 PM
Conditional Format Advanced Tiegris Excel Worksheet Functions 2 November 8th 04 05:46 PM


All times are GMT +1. The time now is 10:44 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"