ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   use macro on a protected sheet (https://www.excelbanter.com/excel-programming/325219-use-macro-protected-sheet.html)

das.s.k

use macro on a protected sheet
 
If i protect a worksheet the macro is not executing. it is giving error
message as
Run-Time Error 1004
You cannot use this command in a protected sheet.

kindly suggest the procedure to execute the macro in a protected sheet. i
want to protect some cells in the sheet from being uptaion.

JulieD

use macro on a protected sheet
 
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


"das.s.k" wrote in message
...
If i protect a worksheet the macro is not executing. it is giving error
message as
Run-Time Error 1004
You cannot use this command in a protected sheet.

kindly suggest the procedure to execute the macro in a protected sheet. i
want to protect some cells in the sheet from being uptaion.




Tony

use macro on a protected sheet
 
If you are protecting the worksheet from the VBA code you
might try this:

Dim x as Boolean

x = Worhsheets(1).Protect_
(DrawingObjects:=True, Contents:=True, _
Scenarios:=True, UserInterfaceOnly:=True)

The last arg sets the protection so that a macro can alter
the sheet but a user cannot.

Hope this helps

Tony
-----Original Message-----
If i protect a worksheet the macro is not executing. it

is giving error
message as
Run-Time Error 1004
You cannot use this command in a protected sheet.

kindly suggest the procedure to execute the macro in a

protected sheet. i
want to protect some cells in the sheet from being

uptaion.
.



All times are GMT +1. The time now is 12:22 AM.

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