Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Colouring cells

As you can only do 3 conditional formats - I have been
pointed to donig this is VB. Any ideas!!
I want to colour cells if the value is equal to a number -
1,2,3,4 or 5. Need to be a different colour for each
result.
thanks
Sam
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 292
Default Colouring cells

Hi Sam

Sub test()
With ActiveCell
Select Case .Value
Case 1
.Interior.ColorIndex = 12
Case 2
.Interior.ColorIndex = 19
Case 3
.Interior.ColorIndex = 23
Case 4
.Interior.ColorIndex = 5
Case 5
.Interior.ColorIndex = 36
Case Else
.Interior.ColorIndex = xlNone
End Select
End With
End Sub

Replace "Activecell" with whatever single-cell range you want to colorize.

HTH. Best wishes Harald

"Sam A" skrev i melding
...
As you can only do 3 conditional formats - I have been
pointed to donig this is VB. Any ideas!!
I want to colour cells if the value is equal to a number -
1,2,3,4 or 5. Need to be a different colour for each
result.
thanks
Sam



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Colouring cells

Option Explicit

Sub ColorSelection()
Dim varr As Variant
Dim cell As Range
varr = Array(3, 6, 8, 20, 15) ' array of color indexes corresponding to
number 1 to 5
For Each cell In Selection
If IsNumeric(cell.Value) Then
If CLng(cell.Value) = 1 And CLng(cell.Value) <= 5 Then
cell.Interior.ColorIndex = varr(CLng(cell.Value) + (LBound(varr) =
0))
End If
End If
Next
End Sub


--
Regards,
Tom Ogilvy



"Sam A" wrote in message
...
As you can only do 3 conditional formats - I have been
pointed to donig this is VB. Any ideas!!
I want to colour cells if the value is equal to a number -
1,2,3,4 or 5. Need to be a different colour for each
result.
thanks
Sam



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
Colouring Ranges & Leaving Cells Blank klam Excel Discussion (Misc queries) 1 May 2nd 07 03:45 PM
automate the colouring of lots of cells [email protected] Excel Discussion (Misc queries) 1 September 26th 06 10:42 AM
Excel Macro for colouring cells Flash Excel Discussion (Misc queries) 2 July 13th 06 06:18 PM
Automatic colouring of cells Hustler24 Excel Discussion (Misc queries) 2 June 28th 06 09:18 AM
Automatic colouring of cells plf100 Excel Worksheet Functions 3 March 29th 06 03:10 PM


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