ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Allow user to run a macro in protected mode (https://www.excelbanter.com/excel-discussion-misc-queries/57012-allow-user-run-macro-protected-mode.html)

Jean Cloutier

Allow user to run a macro in protected mode
 
I want to let other users of my spreadsheet to run a macro in protected mode.

The macro runs the filter for a big spreadsheet and I want to keep the
protection on but let users run the simple macro that hides the blank lines
with auto-filters.

Users get Run-time error 1004 when they click on my macro icon

goober

Allow user to run a macro in protected mode
 

The cells you are manipulating have to be unprotected during the
manipulation.

You can do this by putting this piece of code at the beginning of your
macro.

Dim Code
Code = "password"
Worksheets("sheetname).Unprotect (PrivCode)

Then at the end of your code put this

Worksheets("sheetname).Protect (PrivCode)

You will have to password protect your VBA editor for that Workbook but
this will allow the macro to change the sheet as it needs to.


--
goober
------------------------------------------------------------------------
goober's Profile: http://www.excelforum.com/member.php...o&userid=19838
View this thread: http://www.excelforum.com/showthread...hreadid=487761


dominicb

Allow user to run a macro in protected mode
 

Good evening Jean Cloutier

You should be able to run a macro in a protected sheet. The error will
be caused by attempting to filter items in a protected sheet.

If you are using Excel 2002 or higher, you can set the filter to run in
a protected sheet from the protection dialog.

If you are using XL2000 or prior, then look here to see how to handle
filters in a protected sheet:

http://www.contextures.com/xlautofilter03.html#Protect

HTH

DominicB


--
dominicb
------------------------------------------------------------------------
dominicb's Profile: http://www.excelforum.com/member.php...o&userid=18932
View this thread: http://www.excelforum.com/showthread...hreadid=487761



All times are GMT +1. The time now is 05:59 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com