Ironman
Well-known Member
- Joined
- Jan 31, 2004
- Messages
- 1,069
- Office Version
- 365
- Platform
- Windows
Hi
Can you tell me why the first part works fine but the second part doesn't?
I'm guessing it's because the target column is D not C but I don't know how to code it to get both parts to work.
I'd be grateful for some code that will do this.
Many thanks!
Can you tell me why the first part works fine but the second part doesn't?
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 4 And Target.Row = Range("A" & Rows.Count).End(xlUp).Row Then
Lr1 = Target.Row
'this part works fine
If Sheets("Training Log").Range("D" & Lr1).Value >= 0.0833 And Sheets("Training Log").Range("D" & Lr1).Value < 0.1249 Then
Sheets("Training Log").Range("D" & Lr1).Resize(, 1).Interior.Color = RGB(255, 204, 153)
End If
If Sheets("Training Log").Range("D" & Lr1).Value >= 0.125 And Sheets("Training Log").Range("D" & Lr1).Value < 0.1458 Then
Sheets("Training Log").Range("D" & Lr1).Resize(, 1).Interior.Color = RGB(191, 191, 191)
End If
If Sheets("Training Log").Range("D" & Lr1).Value >= 0.1459 And Sheets("Training Log").Range("D" & Lr1).Value < 0.1665 Then
Sheets("Training Log").Range("D" & Lr1).Resize(, 1).Interior.Color = RGB(255, 204, 0)
End If
If Sheets("Training Log").Range("D" & Lr1).Value >= 0.1667 Then
Sheets("Training Log").Range("D" & Lr1).Resize(, 1).Interior.Color = RGB(242, 242, 242)
End If
'this part doesn't (no error but no fill either)
If Sheets("Training Log").Range("C" & Lr1).Value >= 9.9 And Sheets("Training Log").Range("C" & Lr1).Value < 13.2 Then
Sheets("Training Log").Range("C" & Lr1).Interior.Color = RGB(255, 204, 153)
End If
If Sheets("Training Log").Range("C" & Lr1).Value >= 13.2 And Sheets("Training Log").Range("C" & Lr1).Value < 15.1 Then
Sheets("Training Log").Range("C" & Lr1).Interior.Color = RGB(191, 191, 191)
End If
If Sheets("Training Log").Range("C" & Lr1).Value >= 15.1 And Sheets("Training Log").Range("C" & Lr1).Value < 17 Then
Sheets("Training Log").Range("C" & Lr1).Interior.Color = RGB(255, 204, 0)
End If
If Sheets("Training Log").Range("C" & Lr1).Value >= 17 Then
Sheets("Training Log").Range("C" & Lr1).Interior.Color = RGB(242, 242, 242)
End If
End If
End If
I'd be grateful for some code that will do this.
Many thanks!
Last edited: