Hello!
I am trying to update a worksheet that is supposed to be protected for others to use. I unprotected the worksheet, entered my code, protected the worksheet, then saved it to be Macro compatible and now the code doesn't work.
I did not use a password to protect it. Do I need one?
Current code was derived from a post I found on here from a few years ago. I have not worked with VB code before so this is all new to me!:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count = 1 Then
Dim Colr As Long, Txt As String
If Target.Address(0, 0) = "A5" Then
Txt = "Parent -- Employer"
ElseIf Target.Address(0, 0) = "A14" Then
Txt = "Parent -- Employer"
ElseIf Target.Address(0, 0) = "A23" Then
Txt = "Parent -- Employer"
ElseIf Target.Address(0, 0) = "A30" Then
Txt = "Parent -- Employer"
ElseIf Target.Address(0, 0) = "A37" Then
Txt = "Parent -- Employer"
ElseIf Target.Address(0, 0) = "A44" Then
Txt = "Parent -- Employer"
ElseIf Target.Address(0, 0) = "A51" Then
Txt = "Income Type"
End If
Application.EnableEvents = False
If Len(Target.Value) = 0 Or Target.Value = Txt Then
Target.Font.ColorIndex = 15
Target.Value = Txt
Target.Font.Bold = False
Else
Target.Font.ColorIndex = 13
Target.Font.Bold = True
End If
Application.EnableEvents = True
End If
End Sub
(Summary: I am trying to have specific cells be light in color until someone types in that cell to add information and have it change colors and be bold).
I am trying to update a worksheet that is supposed to be protected for others to use. I unprotected the worksheet, entered my code, protected the worksheet, then saved it to be Macro compatible and now the code doesn't work.
I did not use a password to protect it. Do I need one?
Current code was derived from a post I found on here from a few years ago. I have not worked with VB code before so this is all new to me!:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count = 1 Then
Dim Colr As Long, Txt As String
If Target.Address(0, 0) = "A5" Then
Txt = "Parent -- Employer"
ElseIf Target.Address(0, 0) = "A14" Then
Txt = "Parent -- Employer"
ElseIf Target.Address(0, 0) = "A23" Then
Txt = "Parent -- Employer"
ElseIf Target.Address(0, 0) = "A30" Then
Txt = "Parent -- Employer"
ElseIf Target.Address(0, 0) = "A37" Then
Txt = "Parent -- Employer"
ElseIf Target.Address(0, 0) = "A44" Then
Txt = "Parent -- Employer"
ElseIf Target.Address(0, 0) = "A51" Then
Txt = "Income Type"
End If
Application.EnableEvents = False
If Len(Target.Value) = 0 Or Target.Value = Txt Then
Target.Font.ColorIndex = 15
Target.Value = Txt
Target.Font.Bold = False
Else
Target.Font.ColorIndex = 13
Target.Font.Bold = True
End If
Application.EnableEvents = True
End If
End Sub
(Summary: I am trying to have specific cells be light in color until someone types in that cell to add information and have it change colors and be bold).