How can I run a macro in a protected worksheet?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a worksheet which I want users to enter a limited amount of
information and then I have a a couple of macros that sorts it for them. How
can I run the macro and still protect the worksheet? Any ideas?
 
You cannot run a sort macro in a protected sheet, so you have to unprotect,
do the sort, and protect the sheet again. In a similar post, Julie D posted
the following:

Hi

you'll need to uprotect the sheet at the start of the macro and protect it
again at the end
e.g.

sub mymacro()

activesheet.unprotect ("pwd")
'current code

activesheet.protect ("pwd")
end sub

where pwd is your password

Cheers
JulieD
 
Husker

The easiest method is to unprotect, run your code then re-protect.

Sub Sort_and_stuff()
ActiveSheet.Unprotect Password:="justme"

'do your things or call your macros here

ActiveSheet.Protect Password:="justme", DrawingObjects:=True, _
Contents:=True, Scenarios:=True
End Sub


Gord Dibben Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top