unlocking cells and relocking

apache8119

New Member
Joined
Jul 12, 2012
Messages
34
I am putting together a worksheet that accepts user data. When the user clicks on a cell to sign off requesting the data they input it locks the input cell and a box opens to accept their password. When the correct password is entered it populates the activeCell with their initials and the date next to it. As it goes to the next row down it locks everything above it. All of this is working fine, however if the line below it locks everything above it and the row above hasnt had the intials entered into it already it will not allow you to sign it off. I want to be able to unlock all locked cells and then relock them once the data has been entered. How can I do this I tried doing a selection.locked = false but it gives me an error " Unable to set the locked property of the range class." Please help.

This is what my code looks like

If TextBox1.Value = strPass Then
Range("B8:O8").Select<--This is what I added to try and unlock the cell before it is locked later in the code
Selection.Locked = False
Unload UserForm57
On Error Resume Next
ActiveSheet.Cells(8, 15) = Now()
ActiveCell = " AB "
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

ArthriticPanda

Active Member
Joined
Feb 24, 2013
Messages
292
Hi,

If the sheet is locked down, the sheet may be protected. Try this;
e.g

ActiveSheet.Protect Contents:=False
Selection.Locked = False

AP
 

Snakehips

Well-known Member
Joined
May 17, 2009
Messages
5,162
Office Version
  1. 2013
Platform
  1. Windows
appache8119,

I think you want to be unprotecting then reprotecting.


Assuming there is no password then ActiveSheet.UnProtect will unlock all cells.


Similarly, ActiveSheet.Protect will re-lock all cells that have the locked attribute set to be 'locked'.

Whilst sheet is unprotected, you can if you wish change the 'locked' attribute of any cell or range with

eg Range("A2:B4").Locked = True (or False)

Hope that helps.
 

Watch MrExcel Video

Forum statistics

Threads
1,129,803
Messages
5,638,444
Members
417,025
Latest member
MusterDuster

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top