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 |
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 |
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 . |
All times are GMT +1. The time now is 10:52 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com