Option Button Question

dualhcsniatpac

Board Regular
Joined
Feb 18, 2009
Messages
126
Is there anyway to get an option box to return a number value instead of a true/false value. When I send it to my spreadsheet it keeps coming up as true/false and I want it to be either a 0 for false or 1 for true.

Here is the code I have now:

Code:
        If tacknone.Value = True Then
            tacknone.Value = 1
        Else
            tacknone.Value = 0
        End If
        ActiveCell.Offset(0, 7) = tacknone.Value
        
        If tack1.Value = True Then
            tack1.Value = 1
        Else
            tack1.Value = 0
        End If
        ActiveCell.Offset(0, 8) = tack1.Value
        
        If tack2.Value = True Then
            tack2.Value = 1
        Else
            tack2.Value = 0
        End If
        ActiveCell.Offset(0, 9) = tack2.Value
        
        If tack3.Value = True Then
            tack3.Value = 1
        Else
            tack3.Value = 0
        End If
        ActiveCell.Offset(0, 10) = tack3.Value
        
        If tack4.Value = True Then
            tack4.Value = 1
        Else
            tack4.Value = 0
        End If
        ActiveCell.Offset(0, 11) = tack4.Value

The option buttons are in a frame so only 1 is being checked at a time.

Thanks for the help.
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Hi dualhcsniatpac,

As the option box value is a boolean type it will return true/false based on whether a 1 or a 0 (respectively) is assigned to it. To return the numeric equivalent (or any value for that matter) of true or false use the following example for each option box:

Code:
If tacknone.Value = True Then
        ActiveCell.Offset(0, 7).Value = 1
    Else
        ActiveCell.Offset(0, 7).Value = 0
    End If

HTH

Robert
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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