LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Interior color disappears

I Use the following code to set the interior color af a cell:


Private Sub Worksheet_Change(ByVal Target As Excel.Range)

Application.ScreenUpdating = False

If Not Intersect(Target, Range("$M6:$M1006")) Is Nothing Then

With Target

Select Case .Value
Case Is = "Nld", "Bel"
.Offset(0, -11).Resize(1, 3).Interior.ColorIndex = 35
Case Else
.Offset(0, -11).Resize(1, 3).Interior.ColorIndex = xlNone
End Select

End With
End If

End Sub


and this to color a selected row:


Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Application.ScreenUpdating = False

If Intersect(ActiveCell, Range("B6:AO1006")) Is Nothing Then Exit Sub

Dim RngRow As Range
Dim RngCol As Range
Dim RngFinal As Range
Dim Row As Long
Dim Col As Long

Range("A1:IU6").Cells.Interior.ColorIndex = xlNone
Range("B6:IU1006").Cells.Interior.ColorIndex = xlNone

Row = Target.Row
Col = Target.Column

Set RngRow = Range("B" & Row, Range("AO" & Row, Target))
Set RngCol = Range(Cells(1, Col), Target)
Set RngFinal = RngRow

RngFinal.Interior.ColorIndex = 36

Range("B4:AO5").Cells.Interior.ColorIndex = 35

End Sub


Unfortunatly, when I select another cell or row the color, set by the first
part of the code, disappears.

Q:
What would the code be to make sure that I don't loose the interior color if
the conditions in the first part of the code are met and also make sure that
the entire row is colored when the condition is not met.



With kind regards.

Rob Severijns
 
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
Set text color to interior color KJ-clueless Excel Programming 4 September 6th 07 11:34 PM
Interior color [email protected] Excel Programming 2 February 16th 07 09:33 PM
Cell background color (interior color) setting not working Martin E. Excel Programming 1 May 21st 06 07:00 PM
Interior color Paal Excel Programming 0 March 20th 06 02:51 PM
Passing Back Color to Interior Color ExcelMonkey[_190_] Excel Programming 1 March 22nd 05 04:27 PM


All times are GMT +1. The time now is 02:53 AM.

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"