Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 71
Default unprotect sheet macro

Hi All

I have a macro that is listed below
It will be used for security keep people from unauthorized use of my excel
file
Anyways. The macro listed below works gret. However I need to add
additional code to have the macro unprotect each sheet before it can clear
the cells as stated in the original macro.
Is anyone able to help with the code needed to unprotect each sheet.

Private Sub Workbook_Open()
Sheets(1).Activate
If Date Range("A1").Value Then
For Each sh In Sheets
sh.Cells.Clear
Next
ActiveWorkbook.Save
End If
End Sub

Thanks

--
cruchnin numbers
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default unprotect sheet macro

Is it always the same password:

Option Explicit
Private Sub Workbook_Open()
dim Sh as worksheet
dim PWD as string

pwd = "TopSecret

If Date me.sheets(1).Range("A1").Value Then
For Each sh In Sheets
sh.unprotect password:=pwd
sh.Cells.Clear
sh.protect password:=pwd
Next
me.Save
End If
End Sub

But it really won't stop too many people. The ones that want your workbook will
just open a backup version with macros disabled (or just stop those autorunning
macros).

belvy123 wrote:

Hi All

I have a macro that is listed below
It will be used for security keep people from unauthorized use of my excel
file
Anyways. The macro listed below works gret. However I need to add
additional code to have the macro unprotect each sheet before it can clear
the cells as stated in the original macro.
Is anyone able to help with the code needed to unprotect each sheet.

Private Sub Workbook_Open()
Sheets(1).Activate
If Date Range("A1").Value Then
For Each sh In Sheets
sh.Cells.Clear
Next
ActiveWorkbook.Save
End If
End Sub

Thanks

--
cruchnin numbers


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,355
Default unprotect sheet macro

Try adding sh.unprotect to your For/Next loop.
--
HTH,
Barb Reinhardt



"belvy123" wrote:

Hi All

I have a macro that is listed below
It will be used for security keep people from unauthorized use of my excel
file
Anyways. The macro listed below works gret. However I need to add
additional code to have the macro unprotect each sheet before it can clear
the cells as stated in the original macro.
Is anyone able to help with the code needed to unprotect each sheet.

Private Sub Workbook_Open()
Sheets(1).Activate
If Date Range("A1").Value Then
For Each sh In Sheets
sh.Cells.Clear
Next
ActiveWorkbook.Save
End If
End Sub

Thanks

--
cruchnin numbers

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
unprotect sheet macro belvy123 Excel Discussion (Misc queries) 1 March 27th 08 11:32 PM
Code to protect/unprotect a sheet using a macro with password FredH Excel Discussion (Misc queries) 5 October 23rd 07 04:49 PM
the unprotect sheet is not highlighted Maddie New Users to Excel 1 April 20th 07 06:24 PM
how to Unprotect sheet mangesh Excel Discussion (Misc queries) 1 July 24th 06 10:34 PM
Macro to Unprotect sheet!? Neo1 Excel Worksheet Functions 5 March 28th 06 05:50 PM


All times are GMT +1. The time now is 11:51 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"