Automatically Locking or Unlocking a Cell..?

Eggspit

New Member
Joined
Oct 23, 2006
Messages
39
Hi..

I have created a form that requires the user to enter details in selected fields.
I lock the worksheet so the user can simply use the tab key to access through the fields that require data inputting..

Some fields only require data if the information entered in a previous cell is a “Y” (yes) rather then an “N” (no).
Is there a way of tidying up my form, so that a cell would automatically Lock or Unlock itself depending on the criteria of a separate cell..?

Example..
Lock cell A1 if cell A2 = “Y”

Currently I have Conditional Formatting to shade out the cells that do not require data, but the user still has to tab through to bypass the un-required cells.

Any help, would be much appreciated..
Thanks loads,

Egg.
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
If you use something like the following, you may get what you want. You need to add this to the worksheet code. In the example below, everytime you change a cell to "Y", the cell to the right of the changed cell unlocks. If you change it to any other value, the cell to the right locks.

You could put in an extra check so that this only happens if the activecell.column = 1 for example

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If ActiveCell.Value = "Y" Then
ActiveCell.Offset(0, 1).Locked = False
Else
ActiveCell.Offset(0, 1).Locked = True
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,571
Messages
6,120,302
Members
448,954
Latest member
EmmeEnne1979

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
Back
Top