Blocking data in cells with checkbox // VBA

Copper Contributor

Hi,

I am addressing you with a question and a problem I encountered while creating a correct Macro/VBA in Excel.

I want to block with a checkbox the content I have in two cells.

These cells are specific because one has a RANDBETWEEN formula and the other has an IF formula (refers in its formula to a cell which is variable also on each click in Excel).

 

I would like the formulas in the cells to work normally when the check box is unchecked, and when it is checked - the values that were in this 2 cells should be blocked and remain as they are.

 

Unfortunately I cannot install Kutools for Excel. Is there any other way to deal with this problem?

Thank you in advance for any advice and help! :)

 

The VBA I've used (**"LockRng" are cells: F3 & G3 that I want to be blocked):

Private Sub CheckBox1_Click()

    Range("LockRng").Select

    On Error Resume Next

    If CheckBox1.Value = True Then

        Selection.Locked = False  

    Else

        Selection.Locked = True   

    End If

End Sub

0 Replies