gpatel_here
New Member
- Joined
- Jan 13, 2015
- Messages
- 11
Hi,
I have a code as below, the Offset Color property is not working, please suggest
I have a code as below, the Offset Color property is not working, please suggest
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim cell As Range
If Not Intersect(Target, Range("C3:AG74")) Is Nothing Then
Unprotect Password:="pass"
For Each cell In Intersect(Target, Range("C3:AG74"))
Select Case cell.Value
Case "A" ' Absent
cell.Interior.Color = RGB(255, 0, 0) ' Dark Red
cell.Offset(1, 0).Interior.Color = RGB(255, 204, 204) 'light red
cell.Offset(1, 0).Locked = True
cell.Offset(1, 0).ClearContents
Case "a" ' Absent
cell = UCase(cell)
Case "p" ' Present
cell = UCase(cell)
Case "P" ' Present
cell.Interior.Color = RGB(97, 243, 63) ' Green
Case "h" ' Half Day
cell = UCase(cell)
Case "H" ' Half Day
cell.Interior.Color = RGB(255, 255, 101) ' Yellow
Case "OF" ' Holiday, Weekly Off
cell.Interior.Color = RGB(242, 220, 219) ' Light Red
cell.Offset(1, 0).Interior.Color = RGB(235, 235, 235)
cell.Offset(1, 0).Locked = True
cell.Offset(1, 0).ClearContents
Case "of" ' Holiday, Weekly Off
cell = UCase(cell)
Case "T" ' Tour
cell.Interior.Color = RGB(184, 204, 228) ' Light Blue
cell.Offset(1, 0).ClearContents
cell.Offset(1, 0).Value = "4"
Case "t" ' Tour
cell = UCase(cell)
Case Else
cell.Interior.ColorIndex = 0
cell.Offset(1, 0).Interior.ColorIndex = 0
cell.Offset(1, 0).Locked = False
End Select
Next cell
'Protect Password:="pass"
End If
Protect Password:="pass"
End Sub