I've had this code for a while, but only recently needed it again, which reminded me to put it up here.
It's a very simple piece of code. The code below applies a password to a worksheet, but leaves autofilter available.
With Worksheets("YourWorkSheet")
EnableAutoFilter = True
Protect Password:="123", Contents:=True, UserInterfaceOnly:=True
End With
EnableAutoFilter = True
Protect Password:="123", Contents:=True, UserInterfaceOnly:=True
End With
As always, hope it proves useful.