ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   using a macro to unproctect a password protected sheet (https://www.excelbanter.com/excel-programming/291110-using-macro-unproctect-password-protected-sheet.html)

paul d

using a macro to unproctect a password protected sheet
 
Is it possible to unprotect a sheet using a macro then manipulate data in the sheet and then repassword protect in the same macro

Chip Pearson

using a macro to unproctect a password protected sheet
 
Paul,

Try something like

Worksheets("Sheet1").Unprotect password:="whatever"
' your code here
Worksheets("Sheet1").Protect password:="whatever"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"paul d" wrote in message
...
Is it possible to unprotect a sheet using a macro then

manipulate data in the sheet and then repassword protect in the
same macro



Gord Dibben

using a macro to unproctect a password protected sheet
 
Paul

Yes it is.

Assuming the sheet has been previously protected with a password

Sub Test()
ActiveSheet.Unprotect Password:="password"

'do your manipulation steps here

ActiveSheet.Protect Password:="password", DrawingObjects:=True, _
Contents:=True, Scenarios:=True

End Sub

Gord Dibben Excel MVP



On Wed, 11 Feb 2004 16:31:05 -0800, paul d
wrote:

Is it possible to unprotect a sheet using a macro then manipulate data in the sheet and then repassword protect in the same macro



paul d

using a macro to unproctect a password protected sheet
 

You're a lifesaver works perfectl
----- Chip Pearson wrote: ----

Paul

Try something lik

Worksheets("Sheet1").Unprotect password:="whatever
' your code her
Worksheets("Sheet1").Protect password:="whatever


--
Cordially
Chip Pearso
Microsoft MVP - Exce
Pearson Software Consulting, LL
www.cpearson.co


"paul d" wrote in messag
..
Is it possible to unprotect a sheet using a macro the

manipulate data in the sheet and then repassword protect in th
same macr




paul d

using a macro to unproctect a password protected sheet
 
thank you so much works perfectly


All times are GMT +1. The time now is 02:17 PM.

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