This sub works great; however, as soon as you protect the code; e.g., (View Code), (Tools), (VBAProject - Project Properties), (Proctection) and click the (Lock project for viewing) box and enter a password, the code stops working and I get the Runtime error '1004'. I would like to protect this code. Thanks.
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$J$1" Then
Select Case Target.Value
Case "Clear":
Range("A2:H2").Select
Range(Selection, Selection.End(xlDown)).Select
Range("A2:H2001").Select
Selection.ClearContents
Range("J3").Select
ActiveCell.FormulaR1C1 = "=IF(R2C1<>"""",""¡ Click Here !"","""")"
Range("L1").Select
ActiveCell.FormulaR1C1 = "=R[2]C[-2]&"" ""&R[1]C[-10]&""-""&R[1]C[-11]"
Range("J1").Activate
Selection.ClearContents
Range("A2").Select
Case "Ready for Upload":
Range("A2").Select
Sheets("Uploadable").Select
Application.Goto Reference:="Paste"
Selection.ClearContents
Sheets("Conversion").Visible = True
Sheets("Conversion").Select
Application.Goto Reference:="Copy"
Selection.Copy
Sheets("Uploadable").Select
Application.Goto Reference:="Paste"
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Conversion").Select
Application.CutCopyMode = False
Sheets("Conversion").Visible = xlVeryHidden
Sheets("Paste Special Data (A2)").Select
Range("A2").Select
Case "Save":
Sheets("Uploadable").Select
ChDir "G:\File Name\6I - Upload Files (2022)"
ActiveWorkbook.SaveAs Filename:= _
"G:\File Name\6I - Upload Files (2022)\" & Range("L1") & ".csv", _
FileFormat:=xlCSVUTF8, CreateBackup:=False
End Select
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$J$1" Then
Select Case Target.Value
Case "Clear":
Range("A2:H2").Select
Range(Selection, Selection.End(xlDown)).Select
Range("A2:H2001").Select
Selection.ClearContents
Range("J3").Select
ActiveCell.FormulaR1C1 = "=IF(R2C1<>"""",""¡ Click Here !"","""")"
Range("L1").Select
ActiveCell.FormulaR1C1 = "=R[2]C[-2]&"" ""&R[1]C[-10]&""-""&R[1]C[-11]"
Range("J1").Activate
Selection.ClearContents
Range("A2").Select
Case "Ready for Upload":
Range("A2").Select
Sheets("Uploadable").Select
Application.Goto Reference:="Paste"
Selection.ClearContents
Sheets("Conversion").Visible = True
Sheets("Conversion").Select
Application.Goto Reference:="Copy"
Selection.Copy
Sheets("Uploadable").Select
Application.Goto Reference:="Paste"
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Conversion").Select
Application.CutCopyMode = False
Sheets("Conversion").Visible = xlVeryHidden
Sheets("Paste Special Data (A2)").Select
Range("A2").Select
Case "Save":
Sheets("Uploadable").Select
ChDir "G:\File Name\6I - Upload Files (2022)"
ActiveWorkbook.SaveAs Filename:= _
"G:\File Name\6I - Upload Files (2022)\" & Range("L1") & ".csv", _
FileFormat:=xlCSVUTF8, CreateBackup:=False
End Select
End If
End Sub