Run-Time error '1004' Application-defined or object-defined error

mlee3

Board Regular
Joined
May 6, 2008
Messages
70
Hello. The follow codes worked before I protected the sheet. However, the job stopped in the red statement and pop up the Run-Time error '1004' after I protected the worksheet. Can anyone please help? I highly appreciate!

Private Sub Worksheet_Change(ByVal Target As Range)
ThisWorkbook.Worksheets("test").Protect Password:="test", UserinterfaceOnly:=True



Dim LRow As Integer
LRow = Sheets("draft").Range("A65536").End(xlUp).Row
ActiveWorkbook.Names("GroupName").Delete
Sheets("draft").Range("A2:A" & LRow).Name = "GroupName"
Range("L" & ActiveCell.Row).ClearContents
With Range("L" & ActiveCell.Row)
With .Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="=GroupName"
End With
End With

End Sub
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Change your second line to .UnProtect, not .Protect.

Then, put this line of code AFTER the last End With and above End sub


Code:
ThisWorkbook.Worksheets("test").Protect Password:="test", UserinterfaceOnly:=True
 
Upvote 0
Thank you very much! Your codes did not make it work exactly what I want but I adjusted and figured it out based on your input.
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,208
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top