#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 349
Default worksheet protection

Hi

I know how to password protect a worksheet - but is it possible to not have
to keep re-protecting the sheet after I have made changes.

Spreadsheet will be saved on a shared drive - but not a shared workbook. I
want to be able to unhide columns and make changes then re hide these columns
and save - but don't want to have to keep protecting the worksheet/workbook.

Any ideas? (maybe a simple macro if no obvious way)

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default worksheet protection

Peter,

Do it using the before close event


Private Sub Workbook_BeforeClose(Cancel As Boolean)
Sheets("Sheet1").Protect Password:="Mypass"
End Sub

Mike

"Peter" wrote:

Hi

I know how to password protect a worksheet - but is it possible to not have
to keep re-protecting the sheet after I have made changes.

Spreadsheet will be saved on a shared drive - but not a shared workbook. I
want to be able to unhide columns and make changes then re hide these columns
and save - but don't want to have to keep protecting the worksheet/workbook.

Any ideas? (maybe a simple macro if no obvious way)

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 349
Default worksheet protection

Hi Mike

Thanks for this - it works wonders, I was trying to add an extra step before
saving the spreadsheet and that is to hide the specific columns - using the
following:

Sheets("Sheet1").Columns("D:H").Select
Selection.EntireColumn.Hidden = True

this works providing I have unprotected the sheet and left the columns
unhidden - if I open the sheet and close it without changes then I get a
run-time error (obviously it is trying to hide columns that are already
hidden).

Is there away round this?

"Mike H" wrote:

Peter,

Do it using the before close event


Private Sub Workbook_BeforeClose(Cancel As Boolean)
Sheets("Sheet1").Protect Password:="Mypass"
End Sub

Mike

"Peter" wrote:

Hi

I know how to password protect a worksheet - but is it possible to not have
to keep re-protecting the sheet after I have made changes.

Spreadsheet will be saved on a shared drive - but not a shared workbook. I
want to be able to unhide columns and make changes then re hide these columns
and save - but don't want to have to keep protecting the worksheet/workbook.

Any ideas? (maybe a simple macro if no obvious way)

Thanks

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default worksheet protection

Peter,

Unprotect it first, it won't throw an error if it's already unprotected

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Sheets("Sheet1").Unprotect Password:="Mypass"
Sheets("Sheet1").Columns("D:H").Select
Selection.EntireColumn.Hidden = True
Sheets("Sheet1").Protect Password:="Mypass"
End Sub

Mike

"Peter" wrote:

Hi Mike

Thanks for this - it works wonders, I was trying to add an extra step before
saving the spreadsheet and that is to hide the specific columns - using the
following:

Sheets("Sheet1").Columns("D:H").Select
Selection.EntireColumn.Hidden = True

this works providing I have unprotected the sheet and left the columns
unhidden - if I open the sheet and close it without changes then I get a
run-time error (obviously it is trying to hide columns that are already
hidden).

Is there away round this?

"Mike H" wrote:

Peter,

Do it using the before close event


Private Sub Workbook_BeforeClose(Cancel As Boolean)
Sheets("Sheet1").Protect Password:="Mypass"
End Sub

Mike

"Peter" wrote:

Hi

I know how to password protect a worksheet - but is it possible to not have
to keep re-protecting the sheet after I have made changes.

Spreadsheet will be saved on a shared drive - but not a shared workbook. I
want to be able to unhide columns and make changes then re hide these columns
and save - but don't want to have to keep protecting the worksheet/workbook.

Any ideas? (maybe a simple macro if no obvious way)

Thanks

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 349
Default worksheet protection

Mike,

You make it look so simple - you have been a great help

Thanks


"Mike H" wrote:

Peter,

Unprotect it first, it won't throw an error if it's already unprotected

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Sheets("Sheet1").Unprotect Password:="Mypass"
Sheets("Sheet1").Columns("D:H").Select
Selection.EntireColumn.Hidden = True
Sheets("Sheet1").Protect Password:="Mypass"
End Sub

Mike

"Peter" wrote:

Hi Mike

Thanks for this - it works wonders, I was trying to add an extra step before
saving the spreadsheet and that is to hide the specific columns - using the
following:

Sheets("Sheet1").Columns("D:H").Select
Selection.EntireColumn.Hidden = True

this works providing I have unprotected the sheet and left the columns
unhidden - if I open the sheet and close it without changes then I get a
run-time error (obviously it is trying to hide columns that are already
hidden).

Is there away round this?

"Mike H" wrote:

Peter,

Do it using the before close event


Private Sub Workbook_BeforeClose(Cancel As Boolean)
Sheets("Sheet1").Protect Password:="Mypass"
End Sub

Mike

"Peter" wrote:

Hi

I know how to password protect a worksheet - but is it possible to not have
to keep re-protecting the sheet after I have made changes.

Spreadsheet will be saved on a shared drive - but not a shared workbook. I
want to be able to unhide columns and make changes then re hide these columns
and save - but don't want to have to keep protecting the worksheet/workbook.

Any ideas? (maybe a simple macro if no obvious way)

Thanks



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
Worksheet Protection wx4usa Excel Discussion (Misc queries) 1 January 10th 07 02:11 PM
Cell Protection vs. Worksheet Protection kmwhitt Excel Discussion (Misc queries) 4 September 24th 06 02:37 AM
Worksheet protection is gone and only wokbook protection can be se Eric C. Excel Discussion (Misc queries) 4 May 2nd 06 04:50 PM
Worksheet protection inay Excel Discussion (Misc queries) 0 February 23rd 06 10:35 PM
Worksheet Protection Connie Martin Excel Discussion (Misc queries) 4 December 28th 05 03:56 PM


All times are GMT +1. The time now is 10:24 AM.

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

About Us

"It's about Microsoft Excel"