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

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
@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
 
Upvote 0
Solution

Forum statistics

Threads
1,223,888
Messages
6,175,215
Members
452,618
Latest member
Tam84

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