I have the following vba code that works exactly as expected, except for one thing.
so this is set into a tracking worksheet. the purpose of the worksheet is to determine whether something is done or not with 1's and 0's, and then figures the percentage complete... blah blah blah.
so when the user enters 1 on the sheet (within the range) it changes the interior and font color to green. if the user enters 0 it changes the interior and font color to red.
if the user hit's delete on a cell that has always been empty (never had anything data entered into it) the code works as expected. but if user hit's delete on a cell that has had data entered into it reverts that value back to "0" and the cell turns red.
i need the code to go into the last else statement when the user hits delete within the range (or backspace for that matter). any suggestions would be greatly appreciated.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim inRange As Range
Set inRange = Intersect(Target, Range("C3:N13"))
If (Not (inRange Is Nothing)) Then
If IsEmpty(Target) = False Then
With Target.FormatConditions.Add(xlCellValue, xlEqual, "=0")
.Interior.Color = 255
.Font.Color = 255
End With
With Target.FormatConditions.Add(xlCellValue, xlGreater, 0)
.Interior.Color = -11489280
.Font.Color = -11489280
End With
Else
With Target.Borders
.LineStyle = xlContinuous
.Weight = xlThin
End With
If Target.Row Mod 2 = 0 Then
With Target.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Else
With Target.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent5
.TintAndShade = 0.799981688894314
.PatternTintAndShade = 0
End With
End If
End If
End If
End Sub
Else
statement. – BigBen