Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 23
Default Protect sheet in macro

Hi,

I have this problem; I have a worksheet that is protected, the user kan
change values in 4 spesific cells. My macro unprotects the sheet, calcualte
and protects the sheet again. Now I would like to protect the sheet so that
it will not be changed by a mistake, so that the user cannot save the changes
in the workbook.

How can I do this?

traima
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default Protect sheet in macro

When you re-protect the sheet in your macro, protect all cells and make locked
cells unselectable.

With ActiveSheet
.Unprotect
.Calculate
.Cells.Select
Selection.Locked = True
.EnableSelection = xlUnlockedCells
.Protect
End With




On Thu, 8 Mar 2007 03:02:08 -0800, traima
wrote:

Hi,

I have this problem; I have a worksheet that is protected, the user kan
change values in 4 spesific cells. My macro unprotects the sheet, calcualte
and protects the sheet again. Now I would like to protect the sheet so that
it will not be changed by a mistake, so that the user cannot save the changes
in the workbook.

How can I do this?

traima


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 23
Default Protect sheet in macro

Hi Gord,

This looks great! And now, how can I aviod that the user unprotecs the sheet
himself? (Tools - protection - unprotect sheet)

If I didn't need this spesific macro, I would password-protect the sheet.
How can I do this in the macro when the user need to run the macro several
times. Is there a way for the macro to type the password to open - and then
passwordprotect it again?

thanks,
traima

Gord Dibben skrev:

When you re-protect the sheet in your macro, protect all cells and make locked
cells unselectable.

With ActiveSheet
.Unprotect
.Calculate
.Cells.Select
Selection.Locked = True
.EnableSelection = xlUnlockedCells
.Protect
End With




On Thu, 8 Mar 2007 03:02:08 -0800, traima
wrote:

Hi,

I have this problem; I have a worksheet that is protected, the user kan
change values in 4 spesific cells. My macro unprotects the sheet, calcualte
and protects the sheet again. Now I would like to protect the sheet so that
it will not be changed by a mistake, so that the user cannot save the changes
in the workbook.

How can I do this?

traima



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default Protect sheet in macro

traima

With ActiveSheet
.Unprotect Password:="justme"
.Calculate
.Cells.Select
Selection.Locked = True
.EnableSelection = xlUnlockedCells
.Protect Password:="justme"
End With

Note: you might want to lock the project also to prevent users from looking at
the code to get the password.

With your workbook open.

Alt + F11, CTRL + r

Right-click on your workbook/project and "Properties"

Select "Protection" tab and "lock project for viewing".

Enter a password.

Note: workbook must be saved/closed and re-opened before the locking takes
effect.


Gord

On Thu, 8 Mar 2007 23:36:28 -0800, traima
wrote:

Hi Gord,

This looks great! And now, how can I aviod that the user unprotecs the sheet
himself? (Tools - protection - unprotect sheet)

If I didn't need this spesific macro, I would password-protect the sheet.
How can I do this in the macro when the user need to run the macro several
times. Is there a way for the macro to type the password to open - and then
passwordprotect it again?

thanks,
traima

Gord Dibben skrev:

When you re-protect the sheet in your macro, protect all cells and make locked
cells unselectable.

With ActiveSheet
.Unprotect
.Calculate
.Cells.Select
Selection.Locked = True
.EnableSelection = xlUnlockedCells
.Protect
End With




On Thu, 8 Mar 2007 03:02:08 -0800, traima
wrote:

Hi,

I have this problem; I have a worksheet that is protected, the user kan
change values in 4 spesific cells. My macro unprotects the sheet, calcualte
and protects the sheet again. Now I would like to protect the sheet so that
it will not be changed by a mistake, so that the user cannot save the changes
in the workbook.

How can I do this?

traima




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
How to protect all sheet ? vumian Excel Worksheet Functions 6 August 4th 06 06:02 PM
Protect Workbook Vs Protect Sheet Poor_pakistani New Users to Excel 4 May 25th 06 02:06 PM
Can I protect columns w/in a "List" using Protect Sheet? Diane Excel Discussion (Misc queries) 0 May 10th 06 03:30 PM
Using macro to un/protect sheet Bonbon Excel Worksheet Functions 2 February 23rd 06 08:14 PM
help with protect sheet WYN Excel Discussion (Misc queries) 14 February 18th 05 10:26 PM


All times are GMT +1. The time now is 12:36 PM.

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"