Conditional Highlighting Cells in a Range
Hi, I'm getting a 'Mismatch' error at the bolded line in the following code:
Sub highlightTable()
Dim cell As Range
Dim counter As Integer
Set cell = Range("E6:G6")
counter = 0
Do While IsEmpty(cell.Offset(0, -1)) = False
If cell.Offset(counter, 0).Value - cell.Offset(counter, -1).Value <= 0.002083334 Then
If cell.Offset(counter, 0) - cell.Offset(counter, -1).Value >= 0 Then
If cell.Offset(counter, 0) - cell.Offset(counter, -1).Value <> Empty Then
With cell.Offset(counter, 0).Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 13408767
.TintAndShade = 0
.PatternTintAndShade = 0
End With
counter = counter + 1
Else
counter = counter + 1
End If
End If
ElseIf cell.Offset(counter, 0).Value - cell.Offset(counter, -1).Value <= 0.003472223 Then
If cell.Offset(counter, 0) - cell.Offset(counter, -1).Value >= 0.0027777777 Then
With cell.Offset(counter, 0).Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 39423
.TintAndShade = 0
.PatternTintAndShade = 0
End With
counter = counter + 1
End If
ElseIf cell.Offset(counter, 0).Value - cell.Offset(counter, -1).Value <= 0.01041666667 Then
If cell.Offset(counter, 0) - cell.Offset(counter, -1).Value >= 0.004166666666 Then
With cell.Offset(counter, 0).Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65280
.TintAndShade = 0
.PatternTintAndShade = 0
End With
counter = counter + 1
End If
ElseIf cell.Offset(counter, 0).Value - cell.Offset(counter, -1).Value <= 0.01180555556 Then
If cell.Offset(counter, 0) - cell.Offset(counter, -1).Value >= 0.011111111111 Then
With cell.Offset(counter, 0).Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 39423
.TintAndShade = 0
.PatternTintAndShade = 0
End With
counter = counter + 1
End If
ElseIf cell.Offset(counter, 0).Value - cell.Offset(counter, -1).Value >= 0.0125 Then
With cell.Offset(counter, 0).Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 13408767
.TintAndShade = 0
.PatternTintAndShade = 0
End With
counter = counter + 1
Else
End
End If
Loop
End Sub
I'm trying to conditionally highlight cells according to the value of the cell's time (hh:mm) minus another cell's time (hh:mm) and am having a problem when I try to use a 3-D range as opposed to just a column of data. Any thoughts?
Recent comments
5 years 34 weeks ago
6 years 20 weeks ago
6 years 32 weeks ago
6 years 35 weeks ago
6 years 36 weeks ago
6 years 42 weeks ago
6 years 50 weeks ago
6 years 50 weeks ago
6 years 50 weeks ago
6 years 50 weeks ago