Checking conditions before enabling a checkbox

Nikhil2803

New Member
Joined
Jul 18, 2023
Messages
37
Office Version
  1. 365
Platform
  1. Windows
I have a checkbox at A5 place. Whenever I want to click on the checkbox, it should check if B5,B6 and B7 contains numeric value. If the conditions meet, then only checkbox should be checked, else user should get a popup that you need to fill B5, B6 and B7 first.
I am using the below code snippets, but it is not working

Function volbl_unitsof_chkbox_Click()

If IsNumeric(Range("D14").Value) > 0 And IsNumeric(Range("D15").Value) > 0 And IsNumeric(Range("D16").Value) > 0 Then
'Range("vbl_unitsof_indicator").Value = True'
volbl_unitsof_chkbox.Enabled = True

Else
Resp1 = MsgBox("Please enter the Units Of amount, maximum amount and Guarentee Issue value ")
If Resp1 = 1 Then
volbl_unitsof_chkbox.Enabled = False
End If

End If
End Function

Can some one please help how to achieve this.
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
I have a checkbox at A5 place. Whenever I want to click on the checkbox, it should check if B5,B6 and B7 contains numeric value. If the conditions meet, then only checkbox should be checked, else user should get a popup that you need to fill B5, B6 and B7 first.
I am using the below code snippets, but it is not working

Function volbl_unitsof_chkbox_Click()

If IsNumeric(Range("D14").Value) > 0 And IsNumeric(Range("D15").Value) > 0 And IsNumeric(Range("D16").Value) > 0 Then
'Range("vbl_unitsof_indicator").Value = True'
volbl_unitsof_chkbox.Enabled = True

Else
Resp1 = MsgBox("Please enter the Units Of amount, maximum amount and Guarentee Issue value ")
If Resp1 = 1 Then
volbl_unitsof_chkbox.Enabled = False
End If

End If
End Function

Can some one please help how to achieve this.
I have a checkbox at A5 place. Whenever I want to click on the checkbox, it should check if B5,B6 and B7 contains numeric value. If the conditions meet, then only checkbox should be checked, else user should get a popup that you need to fill B5, B6 and B7 first.
I am using the below code snippets, but it is not working

Function volbl_unitsof_chkbox_Click()

If IsNumeric(Range("D14").Value) > 0 And IsNumeric(Range("D15").Value) > 0 And IsNumeric(Range("D16").Value) > 0 Then
'Range("vbl_unitsof_indicator").Value = True'
volbl_unitsof_chkbox.Enabled = True

Else
Resp1 = MsgBox("Please enter the Units Of amount, maximum amount and Guarentee Issue value ")
If Resp1 = 1 Then
volbl_unitsof_chkbox.Enabled = False
End If

End If
End Function

Can some one please help how to achieve this.
I added the below..

Function volbl_unitsof_chkbox_Click()

If Range("vbl_unitsof_indicator").Value = True And Range("D14").Value And Range("D15").Value And Range("D16").Value Then

volbl_unitsof_chkbox.Enabled = True

ElseIf Range("vbl_unitsof_indicator").Value = False And Range("D14").Value And Range("D15").Value And Range("D16").Value Then

volbl_unitsof_chkbox.Enabled = False

Else
Resp1 = MsgBox("Please enter the Units Of amount, maximum amount and Guarentee Issue value ")
If Resp1 = 1 Then
Range("vbl_unitsof_indicator").Value = False
End If

End If

End Function

still getting Object required error
 
Upvote 0
Please post code within code tags (use vba button on posting toolbar) to maintain indentation and readability. Also, always indicate which line causes an error when stating what the error is. You can use code comments to indicate that.

If you want to know if a cell is numeric, that is the only test you need. I think you are confusing .Value with what that function returns, which is True or False, which just happens to be -1 or 0. If you want to ensure that the value is a number and is greater than zero, that is two tests. That may be why it is "not working" as per your first post, or you might have meant you were getting the same error then as now. Please be clear on what "not working" means as it is of no help to anyone who would try to help you. I also suspect that it is your range reference that is the problem. Provide the full reference and see if that fixes the object error, e.g.
If Sheets("4").range("B1") Then ...
 
Upvote 0
Please post code within code tags (use vba button on posting toolbar) to maintain indentation and readability. Also, always indicate which line causes an error when stating what the error is. You can use code comments to indicate that.

If you want to know if a cell is numeric, that is the only test you need. I think you are confusing .Value with what that function returns, which is True or False, which just happens to be -1 or 0. If you want to ensure that the value is a number and is greater than zero, that is two tests. That may be why it is "not working" as per your first post, or you might have meant you were getting the same error then as now. Please be clear on what "not working" means as it is of no help to anyone who would try to help you. I also suspect that it is your range reference that is the problem. Provide the full reference and see if that fixes the object error, e.g.
If Sheets("4").range("B1") Then ...
Thank you for the inputs. I have fixed the issue. The checkbox.Enabled was causing the error. It is working now.
 
Upvote 0

Forum statistics

Threads
1,224,828
Messages
6,181,201
Members
453,022
Latest member
RobertV1609

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