Results 1 to 10 of 10
  1. #1
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Northern, California, USA
    Posts
    1,886
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Option Button Values

    Does anyone know if there are is a way to assign "0" and "1" to an option button as opposed to "True" and "False?"

    Thanks!
    <IMG SRC=http://www.wopr.com/w3tuserpics/Kel_sig.gif>
    Moderator:<font color=448800> Pix Place, Internet Explorer</font color=448800>
    <small>www.kvisions.com

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Option Button Values

    I'm not sure I understand your question. False and True are 0 and 1. They are just constants that are defined as 0 and one. Therefore, assigning False and True should be identical to assigning 0 and 1. What do you want to do that is different?
    Legare Coleman

  3. #3
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Northern, California, USA
    Posts
    1,886
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Option Button Values

    When I assign the value of an option button from a userform to a worksheet, the value returns "TRUE" or "FALSE" I would like it to display "0" or "1."

    Any Ideas? )

    Thanks!
    <IMG SRC=http://www.wopr.com/w3tuserpics/Kel_sig.gif>
    Moderator:<font color=448800> Pix Place, Internet Explorer</font color=448800>
    <small>www.kvisions.com

  4. #4
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Option Button Values

    Two ways, depending on exactly what you want.

    <pre>Dim nI As Integer
    nI = Me.obName.Value
    Range("A1")Value = nI
    </pre>


    That will put a numeric value in A1 instead of a string. However, it will give you zero for False and -1 for True. If what you want is 1 for True, then you would need to assign Abs(nI) to the cell.
    Legare Coleman

  5. #5
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Northern, California, USA
    Posts
    1,886
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Option Button Values

    Hmm.. Thanks!

    Is there a way to use the countif function in the worksheet based on whether a column's row is occupied?

    For Example, I am using a countif sum to determine how many lawfirms/clients are calling. If the value is true, then it will count the number of true values to return the number of law firms that have called for that day. Now there is a column next to lawfirm/client name that contains date/time. The date/time field is only correct if the user has recorded a call for that row. Do you have any ideas on a countif function that will only count the contents of rows within which the date has been entered?

    Or.. is there a way to display a check/combo box as blank on userform startup? The only method I could think of to do this is to pre-set all values to FALSE, which is causing the problems i'm having with this...

    Thanks!
    <IMG SRC=http://www.wopr.com/w3tuserpics/Kel_sig.gif>
    Moderator:<font color=448800> Pix Place, Internet Explorer</font color=448800>
    <small>www.kvisions.com

  6. #6
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Option Button Values

    Hi Drk,
    I'm not sure if this is what you're after, but you can set the TripleState property of the checkbox to true and it will then allow nulls as well as true/false.
    Hope that helps.
    Regards,
    Rory

    Microsoft MVP - Excel

  7. #7
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Option Button Values

    The following formula will count the number of non-empty cells in column A:

    <pre>=COUNTIF(A:A,"<>''")
    </pre>


    Is that what you want to do?
    Legare Coleman

  8. #8
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Northern, California, USA
    Posts
    1,886
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Option Button Values

    That might work...

    Column B is either true or false. However, to make the values on my userform appear 'blank', I have put 'False' in each row. I want to count only the 'true' and 'false' values of all rows where "C" has a value...

    any ideas?

    The other option is to use the formula you provided above and subtract it's result from the "False" count...
    <IMG SRC=http://www.wopr.com/w3tuserpics/Kel_sig.gif>
    Moderator:<font color=448800> Pix Place, Internet Explorer</font color=448800>
    <small>www.kvisions.com

  9. #9
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Option Button Values

    I am still having a lot of trouble understanding your question. First, you say that Column B is either true or false, but then you say that you have put 'False' in each row. That would mean that Column B is all false. Second, what do you mean that column B is True or False. Does that mean that column B contains text strings of "True" or "False," or does it contain 0s and 1s or -1s? What exactly do you want to count? Do you want to count rows where column C is not empty and Column B is True, or where column C is not empty and Column B is False, or where column c is not empty and column be is either true or false, or something else?

    You can not do any of these with Countif, but they can be done with an array formula. The following array formula will count all of the rows between 1 and 100 where C is not empty and B is "True":

    <pre>=Sum((c1:c100 <> "") * (B1:B100 = "True"))
    </pre>


    Since that is an array formula, you must hold down the Ctrl+Shift keys when you press enter to enter the formula into the cell. If you do that, Excel will put a {} arounnd the formula if you display it in the formula bar.
    Legare Coleman

  10. #10
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Northern, California, USA
    Posts
    1,886
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Option Button Values

    [img]/w3timages/icons/beep.gif[/img] Not sure how I could have been more clear, but thanks, that's exactly what I wanted to do. [img]/w3timages/icons/wink.gif[/img]

    Thanks again Legare!
    <IMG SRC=http://www.wopr.com/w3tuserpics/Kel_sig.gif>
    Moderator:<font color=448800> Pix Place, Internet Explorer</font color=448800>
    <small>www.kvisions.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •