Hello Excel champions of the world!
I am having a confusing problem...
All my code seems to work just fine until I protect the worksheet, I get run-time error '1004': application-defined or object-defined error. The code underlined is where the first hit comes into play and I am not understanding why. If the code works when not protected, why is it yelling at me when protected? My cells are merged, not sure if that is the issue...I understand that merged cells create a lot of hassle, but I need them.
I am having a confusing problem...
All my code seems to work just fine until I protect the worksheet, I get run-time error '1004': application-defined or object-defined error. The code underlined is where the first hit comes into play and I am not understanding why. If the code works when not protected, why is it yelling at me when protected? My cells are merged, not sure if that is the issue...I understand that merged cells create a lot of hassle, but I need them.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If IsEmpty(Cells(19, 3)) Then 'if empty, put in "Value" and make value change text to teal.
Cells(19, 3).Value = "123456"
Cells(19, 3).Font.ColorIndex = 14
ElseIf Sheet1.Cells(19, 3).Value = "123456" Then 'if equal to "Value", change text to teal.
[U]Cells(19, 3).Font.ColorIndex = 14[/U]
ElseIf Sheet1.Cells(19, 3).Value <> "123456" Then 'if text other than "Value", change text to black.
Cells(19, 3).Font.ColorIndex = 1
End If
End Sub