ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Checkbox locked and will not unlock (https://www.excelbanter.com/excel-programming/345484-checkbox-locked-will-not-unlock.html)

Rmagic[_5_]

Checkbox locked and will not unlock
 

Hello

I have a checkbox that i only want to become unlocked when a number is
put in this is my code
Private Sub CheckBox1_Click()

If ("N22") = "1" Or "2" Or "3" Then
CheckBox1.Value = False
CheckBox1.Enabled = False
Else
CheckBox1.Value = False
CheckBox1.Enabled = True

End If



End Sub

But it only works once and when you put other numbers in it still
remains locked??????


--
Rmagic
------------------------------------------------------------------------
Rmagic's Profile: http://www.excelforum.com/member.php...o&userid=28595
View this thread: http://www.excelforum.com/showthread...hreadid=484673


Tom Ogilvy

Checkbox locked and will not unlock
 
Private Sub CheckBox1_Click()

If Range("N22").Text = "1" Or _
Range("N22").text = "2" Or _
Range("N22").text = "3" Then
CheckBox1.Value = False
CheckBox1.Enabled = False
Else
CheckBox1.Value = False
CheckBox1.Enabled = True

End If
End Sub

--
Regards,
Tom Ogilvy


"Rmagic" wrote in
message ...

Hello

I have a checkbox that i only want to become unlocked when a number is
put in this is my code
Private Sub CheckBox1_Click()

If ("N22") = "1" Or "2" Or "3" Then
CheckBox1.Value = False
CheckBox1.Enabled = False
Else
CheckBox1.Value = False
CheckBox1.Enabled = True

End If



End Sub

But it only works once and when you put other numbers in it still
remains locked??????


--
Rmagic
------------------------------------------------------------------------
Rmagic's Profile:

http://www.excelforum.com/member.php...o&userid=28595
View this thread: http://www.excelforum.com/showthread...hreadid=484673




Rmagic[_6_]

Checkbox locked and will not unlock
 

Hi i have tried the code (thanks for that)


Private Sub CheckBox1_Click()

If Range("N22").Text = "1" Or _
Range("N22").text = "2" Or _
Range("N22").text = "3" Then
CheckBox1.Value = False
CheckBox1.Enabled = False
Else
CheckBox1.Value = False
CheckBox1.Enabled = True

End If
End Sub


But it only works once and still remains locked after change the numbe
to say 4 or 5

Thank

--
Rmagi
-----------------------------------------------------------------------
Rmagic's Profile: http://www.excelforum.com/member.php...fo&userid=2859
View this thread: http://www.excelforum.com/showthread.php?threadid=48467


Tom Ogilvy

Checkbox locked and will not unlock
 
I only straightened out your existing code. I didn't comment on the logic
you are employing.

If the checkbox is not enabled, then you can not fire the click event and
re-enable the control. You will need to use the Change event or the
Calculate event of the worksheets to reenable the control (and possibly
disable it).

--
Regards,
Tom Ogilvy


"Rmagic" wrote in
message ...

Hi i have tried the code (thanks for that)


Private Sub CheckBox1_Click()

If Range("N22").Text = "1" Or _
Range("N22").text = "2" Or _
Range("N22").text = "3" Then
CheckBox1.Value = False
CheckBox1.Enabled = False
Else
CheckBox1.Value = False
CheckBox1.Enabled = True

End If
End Sub


But it only works once and still remains locked after change the number
to say 4 or 5

Thanks


--
Rmagic
------------------------------------------------------------------------
Rmagic's Profile:

http://www.excelforum.com/member.php...o&userid=28595
View this thread: http://www.excelforum.com/showthread...hreadid=484673





All times are GMT +1. The time now is 03:17 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com