LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
dd dd is offline
external usenet poster
 
Posts: 95
Default Worksheet Change Event - Colour infill cells

Hi,

I'm using the following to highlight some cells in my row if the cell in
column 9 contains data.
How do I remove the colour if/when the data is then deleted?

Private Sub Worksheet_Change(ByVal Target As Range)
Dim x As Long, v As Variant
Dim cel As Range
Dim rng As Range
On Error GoTo errExit

Set rng = Intersect(Range(Range("I1"), _
Cells(Range("I500").End(xlUp).Row, 7)), Target)

If Not rng Is Nothing Then
For Each cel In rng
x = 0
With cel
If .Column = 9 Then 'col I

If .Value = "" Then
x = xlNone
Else
x = .Offset(0, -4).Interior.ColorIndex 'col B
End If
If .Interior.ColorIndex < x Then
.Interior.ColorIndex = x
End If

With .Resize(1, 14)
v = .Interior.ColorIndex
If IsNull(v) Then v = -1
If v < x Then
.Interior.ColorIndex = x
End If
End With
End If

If x Then
End If
End With
Next
End If
errExit:
End Sub

Regards
D Dawson


 
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
Event Change on colour index Graham Haughs Excel Programming 1 November 15th 06 10:44 PM
Sort on infill colour Lewej Excel Discussion (Misc queries) 3 August 15th 06 03:24 PM
Cell value change to trigger macro (worksheet change event?) Neil Goldwasser Excel Programming 4 January 10th 06 01:55 PM
Change Cell from Validated List Not Firing Worksheet Change Event [email protected] Excel Programming 3 October 4th 04 03:00 AM


All times are GMT +1. The time now is 11:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"