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

Hi

I have the following code that highlights particular
cells depending or not if they match others.

However, at the moment that will highlight red it they do
but I would like to have it such that if I change one of
the cells so that it no longer matches then it should
retutn to a white background.

Any ideas?

Private Sub Worksheet_Change(ByVal Target As Range)
Dim RwIndex As Integer
Dim CoIndex As Integer
Dim ChkValue As Integer

RwIndex = 9
CoIndex = 4

While Not Cells(RwIndex, CoIndex).Value = ""
ChkValue = Cells(RwIndex, CoIndex).Value
Select Case ChkValue
Case Cells(2, 4)
Cells(RwIndex,
CoIndex).Interior.ColorIndex = 3
Case Cells(2, 5)
Cells(RwIndex,
CoIndex).Interior.ColorIndex = 3
Case Cells(2, 6)
Cells(RwIndex,
CoIndex).Interior.ColorIndex = 3
Case Cells(2, 7)
Cells(RwIndex,
CoIndex).Interior.ColorIndex = 3
Case Cells(2, 8)
Cells(RwIndex,
CoIndex).Interior.ColorIndex = 3
Case Cells(2, 9)
Cells(RwIndex,
CoIndex).Interior.ColorIndex = 3
End Select

CoIndex = CoIndex + 1

If Cells(RwIndex, CoIndex).Value = "" Then
RwIndex = RwIndex + 1
CoIndex = 4
End If

Wend

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Cell Formatting - Continued

Case Cells(2, 9)
Cells(RwIndex,
CoIndex).Interior.ColorIndex = 3
Case Else
Cells(rwIndex,CoIndex).Interior.ColorIndex = xlNone
End Select

--
Regards,
Tom Ogilvy


"Steve" wrote in message
...
Hi

I have the following code that highlights particular
cells depending or not if they match others.

However, at the moment that will highlight red it they do
but I would like to have it such that if I change one of
the cells so that it no longer matches then it should
retutn to a white background.

Any ideas?

Private Sub Worksheet_Change(ByVal Target As Range)
Dim RwIndex As Integer
Dim CoIndex As Integer
Dim ChkValue As Integer

RwIndex = 9
CoIndex = 4

While Not Cells(RwIndex, CoIndex).Value = ""
ChkValue = Cells(RwIndex, CoIndex).Value
Select Case ChkValue
Case Cells(2, 4)
Cells(RwIndex,
CoIndex).Interior.ColorIndex = 3
Case Cells(2, 5)
Cells(RwIndex,
CoIndex).Interior.ColorIndex = 3
Case Cells(2, 6)
Cells(RwIndex,
CoIndex).Interior.ColorIndex = 3
Case Cells(2, 7)
Cells(RwIndex,
CoIndex).Interior.ColorIndex = 3
Case Cells(2, 8)
Cells(RwIndex,
CoIndex).Interior.ColorIndex = 3
Case Cells(2, 9)
Cells(RwIndex,
CoIndex).Interior.ColorIndex = 3
End Select

CoIndex = CoIndex + 1

If Cells(RwIndex, CoIndex).Value = "" Then
RwIndex = RwIndex + 1
CoIndex = 4
End If

Wend

End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default Cell Formatting - Continued

Fantastic

Thank you very much

Regards

Steve
-----Original Message-----
Case Cells(2, 9)
Cells(RwIndex,
CoIndex).Interior.ColorIndex = 3
Case Else
Cells

(rwIndex,CoIndex).Interior.ColorIndex = xlNone
End Select

--
Regards,
Tom Ogilvy


"Steve" wrote in message
...
Hi

I have the following code that highlights particular
cells depending or not if they match others.

However, at the moment that will highlight red it they

do
but I would like to have it such that if I change one

of
the cells so that it no longer matches then it should
retutn to a white background.

Any ideas?

Private Sub Worksheet_Change(ByVal Target As Range)
Dim RwIndex As Integer
Dim CoIndex As Integer
Dim ChkValue As Integer

RwIndex = 9
CoIndex = 4

While Not Cells(RwIndex, CoIndex).Value = ""
ChkValue = Cells(RwIndex, CoIndex).Value
Select Case ChkValue
Case Cells(2, 4)
Cells(RwIndex,
CoIndex).Interior.ColorIndex = 3
Case Cells(2, 5)
Cells(RwIndex,
CoIndex).Interior.ColorIndex = 3
Case Cells(2, 6)
Cells(RwIndex,
CoIndex).Interior.ColorIndex = 3
Case Cells(2, 7)
Cells(RwIndex,
CoIndex).Interior.ColorIndex = 3
Case Cells(2, 8)
Cells(RwIndex,
CoIndex).Interior.ColorIndex = 3
Case Cells(2, 9)
Cells(RwIndex,
CoIndex).Interior.ColorIndex = 3
End Select

CoIndex = CoIndex + 1

If Cells(RwIndex, CoIndex).Value = "" Then
RwIndex = RwIndex + 1
CoIndex = 4
End If

Wend

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
Average With < Continued hamricka[_7_] Excel Worksheet Functions 4 August 20th 09 05:02 PM
Variations on referencing a cell in another workbook - continued Eric Excel Discussion (Misc queries) 4 November 15th 08 04:43 AM
If then statement continued! Add to distribution list without opening Excel Discussion (Misc queries) 1 October 20th 06 11:02 PM
Macro To Change Cell Color (Continued) carl Excel Worksheet Functions 0 March 15th 06 03:10 PM
Cell to Show "Continued" only if > Page 1 Steve Klenner Excel Worksheet Functions 1 April 24th 05 06:15 AM


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