Error message: "expected named parameter" when using AllowFiltering:=True

acolmer

New Member
Joined
Oct 9, 2019
Messages
7
Hi,

I'm a bit of a novice when VBA and have tried a macro that removes a password from a locked excel sheet, does an action and locks the sheet again with the password.

I seem to be unable to enable filtering and sorting, getting the error message "expected named parameter". Is anyone able to help? My code is below:

' DeleteRows Macro
'
'Sub ModifyProtectedSheet()
ActiveSheet.Unprotect Password:="****"
response = MsgBox("Are You Sure You Wish To Delete? Deleted Rows Cannot Be Recovered", vbYesNo)
If response = vbNo Then
MsgBox ("No Entries Deleted")
Exit Sub
End If

-> recorded process here

ActiveSheet.Protect Password:="****", AllowFiltering:=True<strike></strike>, AllowSorting:=True<strike></strike>,<strike></strike>

End Sub

Thanks for your help in advance!
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Hi & welcome to MrExcel.
Remove the comma from the end of the Protect line
 
Upvote 0
Are you sure you have given us the correct code & error message? Fluff has pointed out the problem with the comma at the end of the Protect line, but that would produce a Syntax Error, not the error you have reported.
 
Last edited:
Upvote 0
Peter, I get the same error message as reported by the op.
 
Upvote 0
Peter, I get the same error message as reported by the op.
Hmm, okay, I definitely got a Syntax error. :eek:
Anyway, the main thing is that the problem is fixed. :)
 
Upvote 0
Not sure why we would get different messages, but as you say the main thing is it's fixed.
@acolmer
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,774
Members
452,353
Latest member
strainu

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