Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Temporarily unprotect cell then protect afterwards

is it possbile to lock down every cell in a sheet then when a code is run
temporarily unlock a specific cell allow it to be modified/let a value be
entered in it, then lock the cell again so the user cant type over it?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Temporarily unprotect cell then protect afterwards

The best way to do this is to use the UserInterfaceOnly parameter
of the Protect method. This allows VBA to modify anything, but
locks out the user. Unfortunately, this property is not saved
with the workbook when the workbook is closed, so you'll need to
protect it when the workbook opens. E.g., in the ThisWorkbook
module, use code like

Private Sub Workbook_Open()
Worksheets("Sheet1").Protect Password:="abc",
userinterfaceonly:=True
End Sub


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






"Reggie" wrote in message
...
is it possbile to lock down every cell in a sheet then when a
code is run
temporarily unlock a specific cell allow it to be modified/let
a value be
entered in it, then lock the cell again so the user cant type
over it?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Temporarily unprotect cell then protect afterwards

Select the cells you want to Lock or Unlock using menu
Format--Cells...--Protection. Then use menu Tools--Protection--Protect
Sheet to "Lock out" user entry. In your macro you will have to unprotect
then reprotect the sheet to make changes.

Sheets("Sheet1").Unprotect

(Code here to make changes to cells)

Sheets("Sheet1").Protect _
AllowFormattingCells:=True, _
AllowFormattingColumns:=True, _
AllowFormattingRows:=True, _
AllowSorting:=True, _
AllowFiltering:=True, _
AllowInsertingRows:=True

(Options as necessary, etc.)

"Reggie" wrote:

is it possbile to lock down every cell in a sheet then when a code is run
temporarily unlock a specific cell allow it to be modified/let a value be
entered in it, then lock the cell again so the user cant type over it?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Temporarily unprotect cell then protect afterwards

Much nicer

"Chip Pearson" wrote:

The best way to do this is to use the UserInterfaceOnly parameter
of the Protect method. This allows VBA to modify anything, but
locks out the user. Unfortunately, this property is not saved
with the workbook when the workbook is closed, so you'll need to
protect it when the workbook opens. E.g., in the ThisWorkbook
module, use code like

Private Sub Workbook_Open()
Worksheets("Sheet1").Protect Password:="abc",
userinterfaceonly:=True
End Sub


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






"Reggie" wrote in message
...
is it possbile to lock down every cell in a sheet then when a
code is run
temporarily unlock a specific cell allow it to be modified/let
a value be
entered in it, then lock the cell again so the user cant type
over it?




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Temporarily unprotect cell then protect afterwards

i have only one problem with the code you submitted below...is there anyway
to get the password automatically? what i mean is in the code
"Worksheets("Sheet1").Protect Password:="abc", " where the abc = password, is
there anyway to get this password filled in automatically..Because we want
to be able to change the password without going into the code..

"Chip Pearson" wrote:

The best way to do this is to use the UserInterfaceOnly parameter
of the Protect method. This allows VBA to modify anything, but
locks out the user. Unfortunately, this property is not saved
with the workbook when the workbook is closed, so you'll need to
protect it when the workbook opens. E.g., in the ThisWorkbook
module, use code like

Private Sub Workbook_Open()
Worksheets("Sheet1").Protect Password:="abc",
userinterfaceonly:=True
End Sub


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






"Reggie" wrote in message
...
is it possbile to lock down every cell in a sheet then when a
code is run
temporarily unlock a specific cell allow it to be modified/let
a value be
entered in it, then lock the cell again so the user cant type
over it?




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
Protect or Unprotect Cell dependent on different cell David Bruce Excel Discussion (Misc queries) 2 March 26th 10 02:19 PM
Protect, unprotect Pyrite Excel Discussion (Misc queries) 0 August 15th 08 03:18 PM
protect and unprotect Andrew[_51_] Excel Programming 1 October 13th 05 07:24 PM
protect and unprotect Andrew[_51_] Excel Programming 2 October 13th 05 06:44 PM
Unprotect and protect.... Wilfrid Excel Programming 1 July 28th 04 03:13 AM


All times are GMT +1. The time now is 09:08 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"