using a macro to unproctect a password protected sheet

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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,

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 said:
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

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
 
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 said:
Is it possible to unprotect a sheet using a macro the
manipulate data in the sheet and then repassword protect in th
same macr
 
Back
Top