+ Reply to Thread
Results 1 to 3 of 3

Need the Value of a Checkbox that does not have a default value of True or False

  1. #1
    Registered User
    Join Date
    03-16-2017
    Location
    US
    MS-Off Ver
    2013
    Posts
    8

    Question Need the Value of a Checkbox that does not have a default value of True or False

    Hi,

    I have a userform with a checkbox on it. In the control properties, I cleared the Value, so it does not appear to be set to True or False. I wasn't sure Excel would let me do this, but it appears to be a valid option. When I run the form, the checkbox now has a grayed out checkmark in the box, rather than being blank for False or a solid black check for True.

    I would like to include this grayed out checkbox in my data validations for the userform, but I don't know what the value is to use in an If/Then. I've started writing:

    If (me.checkbox.value <> True And me.checkbox.value <> False) Then

    But that starts to get messy when I also need to include an clause where the checkbox equals True or it equals False.

    I did try to figure it out using the following sub after doing some web research, but the "nothing" if/then turned up an "Invalid use of object" error. So, I commented it out, but the message box for the "null" if/then never popped up.

    Private Sub Userform_Initialize()

    If Me.checkbox.Value = Nothing Then
    MsgBox "value = nothing"
    End If

    If Me.checkbox.Value = Null Then
    MsgBox "value = null"
    End If

    End Sub

    Does anyone know what the value of the checkbox is when it is in its grayed out, no default value state? Any help is greatly appreciated!

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Need the Value of a Checkbox that does not have a default value of True or False

    Make sure that you have "TripleState" property of the checkbox set to "True".

    Then you can check if the value is null like below.
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    03-16-2017
    Location
    US
    MS-Off Ver
    2013
    Posts
    8

    Re: Need the Value of a Checkbox that does not have a default value of True or False

    Thank you CK76! And thank you doubly for showing me the right way to use null.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Change default checkbox output true false into text
    By safonso in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-02-2013, 03:31 PM
  2. Filling in a cell based on Checkbox true/false
    By Rivalwon in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-10-2007, 07:07 PM
  3. Checkbox: If true all others are false?
    By Rick_Stanich in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-03-2007, 11:57 AM
  4. Condition code True False on Checkbox
    By RobertCo in forum Excel General
    Replies: 2
    Last Post: 12-16-2006, 07:47 AM
  5. Replies: 1
    Last Post: 06-06-2006, 03:35 PM
  6. checkbox true/false label
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-04-2005, 12:05 PM
  7. Checkbox toggle true/false
    By Donkin in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-02-2005, 04:37 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1