Macro & Protected sheet

L

Lise

Hello everyone

I have a sheet which is protected so that cells cannot be changed and
formulas are hidden which works well. However I also have a macro on this
sheet which I still want people to be able to use. (see below) I have seen
some answers already but seem to be doing something wrong - what do I need to
add to the below to have the macro only run but keep the actual cells
locked/protected?

Many thanks

Sub Sort()
'
' Sort Macro
' Macro recorded 17/03/2010 by Lisa Senior
'
' Keyboard Shortcut: Ctrl+o
'

Columns("A:A").Select
Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

End Sub
 
G

Garreth Lombard

Hi Lisa,

Paste the code below in a standard module

---------------
Sub Sort_pr_range()
ActiveSheet.Unprotect 'Unprotect the sheet
Range("A1:F100").Sort Key1:=Range("B1"), _ '("A1:F100")would be your range
Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
ActiveSheet.Protect 'Protect the sheet
End Sub
 
L

Lise

Sorry Gareth I must have missed a step as this still gives me the bug alert.

I kept my CTRLO macro alive and added a module with your info below
--

Any assistance would be great

Thanks as always

Lise
 

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

Top