Use of Macros with protected sheets

mesteptoe

Board Regular
Joined
Aug 22, 2008
Messages
105
Is this possible?

I have a series of Worksheets with various formulae on, and cells where data is to be entered. I have locked the formulae cells so that when I put password protection on each Worksheet the formulae cells cannot be altered by mistake - others will use the Worksheet and I don't want it corrupted.

However I normally like to enter macros on sheets to make it easier to move around, e.g.

"Go To" - to move to a particulat Cell on a Worksheet, or to a Cell in another worksheet

"Save and Close" - to save the workbook and quit the Workbook

However, the Macros won't work unless I unprotect the Worksheet. Is there a way of using Macros on a protected Worksheet?

Thanks


Graham
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
In your macro, unprotect the sheet, do your stuff, and protect it again.
 
Upvote 0
You can unprotect it with code

Code:
ActiveSheet.Unprotect password:="xxx"
'
'your code
'
ActiveSheet.Protect password:="xxx"
 
Upvote 0
Hi

But if I insert that extra Code in the Macro, and the Macro is designed to move to a Cell in a completely different Worksheet, or even to Close the Workbook completely, will the instruction to Protect the previous Worksheet still work?

Thanks
 
Upvote 0
Sub goto_SUMMARY()
'
' goto_SUMMARY Macro
' Macro recorded 31/10/2005 by Graham Spicer
'
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p> </o:p>
'
Sheets("SUMMARY").Select
ActiveWindow.SmallScroll ToRight:=-2
ActiveWindow.LargeScroll Down:=-2
Range("B2:B3").Select
End Sub
<o:p> </o:p>
<o:p> </o:p>

<o:p> </o:p>
<o:p> </o:p>
Sub save_and_close()
'
' save_and_close Macro
' Macro recorded 14/07/2006 by Graham Spicer
'
<o:p> </o:p>
'

ActiveWorkbook.save
ActiveWorkbook.Close
End Sub
 
Upvote 0
I don't think that protection should be an issue with your save and close macro. For the other one try

Code:
Sub goto_SUMMARY()
'
' goto_SUMMARY Macro
' Macro recorded 31/10/2005 by Graham Spicer
'

'
With Sheets("SUMMARY")
    .Unprotect password:="xxx"
    Application.Goto .Range("B2:B3")
    .Protect password:="xxx"
End With
End Sub
 
Upvote 0
Sorry to be a pain but wouldn't that Macro rely on having a Password protection for the Workbook as a whole rather than protection of individual Sheets. If I am moving from one sheet to the SUMMARY Sheet I need to maintain individual sheet protection on the Sheet I am moving from.
 
Upvote 0
That code doesn't mind whether the sheet that you are moving from is protected or not.
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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