ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Cell colour doesn't delete (https://www.excelbanter.com/excel-programming/392312-re-cell-colour-doesnt-delete.html)

Sandy

Cell colour doesn't delete
 
Thanks all, Don's suggestion is good for what I want.
Sandy

"Sandy" wrote in message
...
I have the folloing code, why does the cell color in cell C10 not delete
when the value of cell C8 is ""?
Thanks Sandy

Private Sub Worksheet_Change(ByVal Target As Excel.Range)

Application.ScreenUpdating = False

Application.EnableEvents = False

For Each mycell In Range("C8:K8,M8:U8")
With mycell
If mycell.Value = "" Then
.Interior.ColorIndex = 36
.Font.ColorIndex = 1
.BorderAround LineStyle:=xlContinuous, Weight:=xlThin,
ColorIndex:=11
ElseIf mycell.Value < "" Then
.Interior.ColorIndex = 11
.Font.ColorIndex = 45
.Borders.LineStyle = xlNone
End If
End With

With mycell.Offset(2)
If mycell.Value = 0 Then
.Interior.ColorIndex = 11
.Value = ""
ElseIf mycell.Value 0 Then
.Interior.ColorIndex = 36
.Font.ColorIndex = 1
ElseIf mycell.Value = "" Then
.Interior.ColorIndex = xlColorIndexNone
.Value = ""
End If
End With
Next mycell

Application.ScreenUpdating = True

Application.EnableEvents = True

End Sub




Don Guillett

Cell colour doesn't delete
 
Glad to help

--
Don Guillett
SalesAid Software

"Sandy" wrote in message
...
Thanks all, Don's suggestion is good for what I want.
Sandy

"Sandy" wrote in message
...
I have the folloing code, why does the cell color in cell C10 not delete
when the value of cell C8 is ""?
Thanks Sandy

Private Sub Worksheet_Change(ByVal Target As Excel.Range)

Application.ScreenUpdating = False

Application.EnableEvents = False

For Each mycell In Range("C8:K8,M8:U8")
With mycell
If mycell.Value = "" Then
.Interior.ColorIndex = 36
.Font.ColorIndex = 1
.BorderAround LineStyle:=xlContinuous, Weight:=xlThin,
ColorIndex:=11
ElseIf mycell.Value < "" Then
.Interior.ColorIndex = 11
.Font.ColorIndex = 45
.Borders.LineStyle = xlNone
End If
End With

With mycell.Offset(2)
If mycell.Value = 0 Then
.Interior.ColorIndex = 11
.Value = ""
ElseIf mycell.Value 0 Then
.Interior.ColorIndex = 36
.Font.ColorIndex = 1
ElseIf mycell.Value = "" Then
.Interior.ColorIndex = xlColorIndexNone
.Value = ""
End If
End With
Next mycell

Application.ScreenUpdating = True

Application.EnableEvents = True

End Sub






All times are GMT +1. The time now is 02:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com