Disable selection of unlocked cell on locked worksheet without unlocking the sheet

bjkluft

New Member
Joined
Jun 23, 2021
Messages
2
Office Version
  1. 2013
Platform
  1. Windows
Hello,

Hopefully somebody can help me with the following issue. And taking in account that I found a huge amount of solutions already at MrExcel, my expectations are high ;)

I have the following situation:
A password protected worksheet with a specific cell (for example B2) that is unlocked, the user can edit the contents of this cell.
However under specific situations (if, for example, cell A2 has the value FALSE), it is no longer allowed to change the contents of the cell.
Is there a way that I can dynamically disable the contents of that cell?

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  If range("A2").value = "FALSE" then
    range("B2").EnableSelection = False ' I know the EnableSelection is non-existing
  end if
End Sub

Any help would be appriciated!

Kind regards,
Jeroen
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Snakehips

Well-known Member
Joined
May 17, 2009
Messages
5,363
Office Version
  1. 2013
Platform
  1. Windows
@bjkluft Maybe something like this?

VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Target, Range("B2")) Is Nothing Then Exit Sub
If Range("A2") = False Then Range("C2").Select  '<<< edit the alternative selection to suit
End Sub
 
Solution

bjkluft

New Member
Joined
Jun 23, 2021
Messages
2
Office Version
  1. 2013
Platform
  1. Windows
Hi Tony,

Yes that is what I was looking for! Thanks.
 

Forum statistics

Threads
1,141,768
Messages
5,708,416
Members
421,567
Latest member
vicpinto1970

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