Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 49
Default No colour in cells when blank in list

I have the following code already, so when the cell is 0 or 100, it turns
red, 30 turns blue, etc.

However, if I have a blank cell it shows red and I don't want it to have any
colour at all, just the default 'no fill'.

Can anybody help. Many thanks in advance.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim rArea As Range
Dim rCell As Range
Dim nColor As Long
Set Target = Intersect(Target, Range("E:E"))
If Not Target Is Nothing Then
For Each rArea In Target
For Each rCell In rArea
Select Case rCell.Value
Case 0, 100
nColor = RGB(255, 0, 0)
Case 30
nColor = RGB(23, 178, 233)
Case 60
nColor = RGB(245, 200, 11)
Case 90
nColor = RGB(0, 255, 0)
Case Else
nColor = RGB(255, 255, 255)
End Select
If Not nColor = -1 Then _
rCell.Offset(0, -4).Interior.Color = nColor
Next rCell
Next rArea
End If
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,202
Default No colour in cells when blank in list

Add this...

Case ""

in front of all the other Case statements and set the nColor variable to
what you want in there.

Rick


"harwookf" wrote in message
...
I have the following code already, so when the cell is 0 or 100, it turns
red, 30 turns blue, etc.

However, if I have a blank cell it shows red and I don't want it to have
any
colour at all, just the default 'no fill'.

Can anybody help. Many thanks in advance.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim rArea As Range
Dim rCell As Range
Dim nColor As Long
Set Target = Intersect(Target, Range("E:E"))
If Not Target Is Nothing Then
For Each rArea In Target
For Each rCell In rArea
Select Case rCell.Value
Case 0, 100
nColor = RGB(255, 0, 0)
Case 30
nColor = RGB(23, 178, 233)
Case 60
nColor = RGB(245, 200, 11)
Case 90
nColor = RGB(0, 255, 0)
Case Else
nColor = RGB(255, 255, 255)
End Select
If Not nColor = -1 Then _
rCell.Offset(0, -4).Interior.Color = nColor
Next rCell
Next rArea
End If
End Sub



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
Autofilter a list of numbers and blank cells Cheryl Excel Discussion (Misc queries) 3 June 22nd 06 04:50 PM
Eliminating blank cells in a list on a ROW grime Excel Worksheet Functions 5 November 3rd 05 05:41 PM
List not omitting blank cells....?? malik641 Excel Worksheet Functions 2 July 1st 05 04:33 PM
Function to list values of last 3 non-blank cells in a vertical bl ANJ Excel Worksheet Functions 1 April 14th 05 12:53 AM
Eliminate creating list that returns blank cells Marc Todd Excel Worksheet Functions 1 January 26th 05 09:58 PM


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