Checkbox Code

Smurfit-Stone

Active Member
Joined
Dec 1, 2004
Messages
485
Hello Board,

I need code or a formula for a group of three checkboxes I have on a user form. I have checkboxes that if checkbox 1 is checked I want 0 hours to show in cell F13, if checkbox 2 is checked I want 3 hours to show in cell F13, if checkbox 3 is checked I want 6 hours to show in cell F13. So I don't know if I need a macro or an (IF) formula in cell F13. Can anyone help.....I'd greatly appreciate it. Thanks in advance.
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
What if more than one checkbox is checked?
 
Upvote 0
then I'd need an textbox with an error message or make it so only one checkbox can be selected. If you select checkbox 1 then select checkbox 3...checkbox 1 would become unchecked...etc.
 
Upvote 0
Why not use option buttons instead?

Then only 1 option can be picked.
 
Upvote 0
I just created 3 option buttons from the Forms toolbar.

I then created this code in a new module.
Code:
Sub Options()
    Select Case Application.Caller
        Case "Option Button 1"
            x = 0
        Case "Option Button 2"
            x = 3
        Case "Option Button 3"
            x = 6
    End Select
    Range("F13") = x
    
End Sub
I then used Assign Macro... to associate each option button with the code.

Is that the sort of thing you are looking for?
 
Upvote 0
I created the buttons, typed the code in a module and assigned the buttons to the macro. Then when I check any of the controls, I get an "type mismatch" error and its highlights the line of code (Case "Option Button 1"). What should I do now? Thanks in advance.
 
Upvote 0

Forum statistics

Threads
1,214,915
Messages
6,122,212
Members
449,074
Latest member
cancansova

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