Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Automatically locking cells following data entry

I have a workbook that has 25 different worksheets.
The cells are all formatted as locked with the exception
of those that are allowed for data entry. At a point when
all data is added I want to be able to click on a button
that will progress through all worksheets and lock all
cells.

Can anyone please provide me with the code or a macro
that I can assign to a button to do this please.

Thank you in advance.

Brian
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Automatically locking cells following data entry

Application.ScreenUpdating = False
set sh1 = ActiveSheet
for each sh in ThisWorkbook.Worksheets
sh.Activate
Sh.Unprotect Password:="ABCD"
Cells.locked = True
sh.Protect Password:="ABCD"
Next
Sh1.Activate
Application.ScreenUpdating = True

would be a general approach.

--
Regards,
Tom Ogilvy

"Brian Larkin" wrote in message
...
I have a workbook that has 25 different worksheets.
The cells are all formatted as locked with the exception
of those that are allowed for data entry. At a point when
all data is added I want to be able to click on a button
that will progress through all worksheets and lock all
cells.

Can anyone please provide me with the code or a macro
that I can assign to a button to do this please.

Thank you in advance.

Brian



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Automatically locking cells following data entry

Have tried the code and am getting the following error
occur:
Runtime error '1004':
Unable to Set the Locked property of the Range Class.

When I open the debug window, the line of code selected
is Cells.Locked = True

any ideas of how to get this working.
I did try and put in an 'on error resume next' which
seemed to stop any error messages and cells were all
locked and passwords reset, but is worrying that there
may be a bug in the vb code?

Brian
-----Original Message-----
Application.ScreenUpdating = False
set sh1 = ActiveSheet
for each sh in ThisWorkbook.Worksheets
sh.Activate
Sh.Unprotect Password:="ABCD"
Cells.locked = True
sh.Protect Password:="ABCD"
Next
Sh1.Activate
Application.ScreenUpdating = True

would be a general approach.

--
Regards,
Tom Ogilvy

"Brian Larkin" wrote in message
...
I have a workbook that has 25 different worksheets.
The cells are all formatted as locked with the

exception
of those that are allowed for data entry. At a point

when
all data is added I want to be able to click on a

button
that will progress through all worksheets and lock all
cells.

Can anyone please provide me with the code or a macro
that I can assign to a button to do this please.

Thank you in advance.

Brian



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Automatically locking cells following data entry

in a general module, the code works fine for me. You might make a slight
change to make it more robust

Application.ScreenUpdating = False
set sh1 = ActiveSheet
for each sh in ThisWorkbook.Worksheets
sh.Activate
Sh.Unprotect Password:="ABCD"
Sh.Cells.locked = True ' <== add Sh.
sh.Protect Password:="ABCD"
Next
Sh1.Activate
Application.ScreenUpdating = True

would be a general approach.

Regards,
Tom Ogilvy


Brian Larkin wrote in message
...
Have tried the code and am getting the following error
occur:
Runtime error '1004':
Unable to Set the Locked property of the Range Class.

When I open the debug window, the line of code selected
is Cells.Locked = True

any ideas of how to get this working.
I did try and put in an 'on error resume next' which
seemed to stop any error messages and cells were all
locked and passwords reset, but is worrying that there
may be a bug in the vb code?

Brian
-----Original Message-----
Application.ScreenUpdating = False
set sh1 = ActiveSheet
for each sh in ThisWorkbook.Worksheets
sh.Activate
Sh.Unprotect Password:="ABCD"
Cells.locked = True
sh.Protect Password:="ABCD"
Next
Sh1.Activate
Application.ScreenUpdating = True

would be a general approach.

--
Regards,
Tom Ogilvy

"Brian Larkin" wrote in message
...
I have a workbook that has 25 different worksheets.
The cells are all formatted as locked with the

exception
of those that are allowed for data entry. At a point

when
all data is added I want to be able to click on a

button
that will progress through all worksheets and lock all
cells.

Can anyone please provide me with the code or a macro
that I can assign to a button to do this please.

Thank you in advance.

Brian



.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Automatically locking cells following data entry

Tom
I had already tried your suggestion but I am still
getting the same error message.

For additional info I am using Excel97 SR2.
Have tried this on a new workbook and adding data to a
block of cells in each of three worksheets, setting one
column with six rows as unlocked. Then running the code
by clicking the button. The same error message appears.

Any ideas why?

Brian
-----Original Message-----
in a general module, the code works fine for me. You

might make a slight
change to make it more robust

Application.ScreenUpdating = False
set sh1 = ActiveSheet
for each sh in ThisWorkbook.Worksheets
sh.Activate
Sh.Unprotect Password:="ABCD"
Sh.Cells.locked = True ' <== add Sh.
sh.Protect Password:="ABCD"
Next
Sh1.Activate
Application.ScreenUpdating = True

would be a general approach.

Regards,
Tom Ogilvy


Brian Larkin wrote in message
...
Have tried the code and am getting the following error
occur:
Runtime error '1004':
Unable to Set the Locked property of the Range Class.

When I open the debug window, the line of code selected
is Cells.Locked = True

any ideas of how to get this working.
I did try and put in an 'on error resume next' which
seemed to stop any error messages and cells were all
locked and passwords reset, but is worrying that there
may be a bug in the vb code?

Brian
-----Original Message-----
Application.ScreenUpdating = False
set sh1 = ActiveSheet
for each sh in ThisWorkbook.Worksheets
sh.Activate
Sh.Unprotect Password:="ABCD"
Cells.locked = True
sh.Protect Password:="ABCD"
Next
Sh1.Activate
Application.ScreenUpdating = True

would be a general approach.

--
Regards,
Tom Ogilvy

"Brian Larkin" wrote in message
...
I have a workbook that has 25 different worksheets.
The cells are all formatted as locked with the

exception
of those that are allowed for data entry. At a point

when
all data is added I want to be able to click on a

button
that will progress through all worksheets and lock

all
cells.

Can anyone please provide me with the code or a

macro
that I can assign to a button to do this please.

Thank you in advance.

Brian


.



.

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
Locking from data entry but allowing oulining to function? saharafrog Excel Discussion (Misc queries) 1 March 26th 10 08:29 PM
Locking cells automatically after enter HagridC Excel Discussion (Misc queries) 2 February 7th 10 05:34 AM
auto locking cells after new entry/edit patbayns Setting up and Configuration of Excel 1 September 29th 08 11:51 PM
Locking a cell after data entry (Excel 2003) jeffparker98 Excel Discussion (Misc queries) 0 September 19th 08 07:38 PM
Automatically copy previous cells in data entry in Excel Sam Excel Discussion (Misc queries) 1 August 20th 08 10:01 PM


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