Hi all,
I use the code below to color the border of the cell next to K if something is put in column K.
I use Offset for this.
Now i would like to expand this code to other columns but "hard set" that the borders of column C are colored.
So offset doesn't work since the Offset from K to C = -8 but when i want this code from L it isn't -8 but -9.
How do i say column "C" instead of using Target.Offset?
I use the code below to color the border of the cell next to K if something is put in column K.
I use Offset for this.
Now i would like to expand this code to other columns but "hard set" that the borders of column C are colored.
So offset doesn't work since the Offset from K to C = -8 but when i want this code from L it isn't -8 but -9.
How do i say column "C" instead of using Target.Offset?
VBA Code:
If Target.Count > 1 Then Exit Sub
If Not Intersect(Target, Me.Range("K:K")) Is Nothing Then
If Target = vbNullString Then
Target.Offset(0, 1) = vbNullString
Target.Offset(0, 2).Borders(xlEdgeTop).LineStyle = xlNone
Target.Offset(0, 2).Borders(xlEdgeBottom).LineStyle = xlNone
Target.Offset(0, 2).Borders(xlEdgeLeft).LineStyle = xlNone
Target.Offset(0, 2).Borders(xlEdgeLeft).LineStyle = xlContinuous
Target.Offset(0, 2).Borders(xlEdgeRight).Color = RGB(0, 0, 0)
Target.Offset(0, 3).Borders(xlEdgeTop).LineStyle = xlNone
Target.Offset(0, 3).Borders(xlEdgeBottom).LineStyle = xlNone
Target.Offset(0, 3).Borders(xlEdgeRight).LineStyle = xlContinuous
Target.Offset(0, 3).Borders(xlEdgeRight).Color = RGB(0, 0, 0)
Else
Target.Offset(0, 1) = Date
Target.Offset(0, 2).Borders(xlEdgeTop).LineStyle = xlContinuous
Target.Offset(0, 2).Borders(xlEdgeTop).Color = RGB(255, 0, 0)
Target.Offset(0, 2).Borders(xlEdgeBottom).LineStyle = xlContinuous
Target.Offset(0, 2).Borders(xlEdgeBottom).Color = RGB(255, 0, 0)
Target.Offset(0, 2).Borders(xlEdgeLeft).Color = RGB(255, 0, 0)
Target.Offset(0, 2).Borders(xlEdgeRight).Color = RGB(255, 0, 0)
Target.Offset(0, 3).Borders(xlEdgeTop).LineStyle = xlContinuous
Target.Offset(0, 3).Borders(xlEdgeTop).Color = RGB(255, 0, 0)
Target.Offset(0, 3).Borders(xlEdgeBottom).LineStyle = xlContinuous
Target.Offset(0, 3).Borders(xlEdgeBottom).Color = RGB(255, 0, 0)
Target.Offset(0, 3).Borders(xlEdgeRight).LineStyle = xlContinuous
Target.Offset(0, 3).Borders(xlEdgeRight).Color = RGB(255, 0, 0)
End If
ElseIf Not Intersect(Target, Range("M:M")) Is Nothing Then
If Target = vbNullString Then
Target.Offset(0, 1) = vbNullString
Target.Offset(0, 0).Borders(xlEdgeTop).LineStyle = xlContinuous
Target.Offset(0, 0).Borders(xlEdgeBottom).LineStyle = xlContinuous
Target.Offset(0, 0).Borders(xlEdgeRight).LineStyle = xlContinuous
Target.Offset(0, 0).Borders(xlEdgeTop).Color = RGB(255, 0, 0)
Target.Offset(0, 0).Borders(xlEdgeBottom).Color = RGB(255, 0, 0)
Target.Offset(0, 0).Borders(xlEdgeRight).Color = RGB(255, 0, 0)
Target.Offset(0, 0).Borders(xlEdgeLeft).Color = RGB(255, 0, 0)
Target.Offset(0, 1).Borders(xlEdgeTop).LineStyle = xlContinuous
Target.Offset(0, 1).Borders(xlEdgeBottom).LineStyle = xlContinuous
Target.Offset(0, 1).Borders(xlEdgeRight).LineStyle = xlContinuous
Target.Offset(0, 1).Borders(xlEdgeTop).Color = RGB(255, 0, 0)
Target.Offset(0, 1).Borders(xlEdgeBottom).Color = RGB(255, 0, 0)
Target.Offset(0, 1).Borders(xlEdgeRight).Color = RGB(255, 0, 0)
Else
Target.Offset(0, 1) = Date
Target.Offset(0, 0).Borders(xlEdgeTop).LineStyle = xlNone
Target.Offset(0, 0).Borders(xlEdgeBottom).LineStyle = xlNone
Target.Offset(0, 0).Borders(xlEdgeRight).Color = RGB(0, 0, 0)
Target.Offset(0, 0).Borders(xlEdgeLeft).Color = RGB(0, 0, 0)
Target.Offset(0, 1).Borders(xlEdgeTop).LineStyle = xlNone
Target.Offset(0, 1).Borders(xlEdgeBottom).LineStyle = xlNone
Target.Offset(0, 1).Borders(xlEdgeRight).LineStyle = xlNone
Target.Offset(0, 1).Borders(xlEdgeRight).LineStyle = xlContinuous
End If
End If