+ Reply to Thread
Results 1 to 7 of 7

CheckBox state not passing to the sub - Please Help

  1. #1
    Registered User
    Join Date
    12-11-2012
    Location
    Kansas
    MS-Off Ver
    Excel 2011
    Posts
    12

    CheckBox state not passing to the sub - Please Help

    Hi - New to the forum.

    I have the VBA sub below. I can't seem to get it to pass the state of CheckBox9 (which is alway "False"). Can anyone help. please.

    Private Sub CheckBox9_Click()
    '
    ' Macro1 Macro
    '
    Dim aa As Boolean


    If CheckBox9 = True Then
    ActiveSheet.Tab.ColorIndex = 35
    Else
    'If CheckBox9 = False Then
    ActiveSheet.Tab.ColorIndex = 15
    End If


    '
    End Sub

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,705

    Re: CheckBox state not passing to the sub - Please Help

    Welcome to the Forum!

    What do you mean by "pass the state"? The code you showed looks OK but I don't know what you want it to do, so it may not be what you actually need. This Sub is called every time the user clicks on the checkbox, and then it will change the color of the tab of the active sheet accordingly. Where is the checkbox, and where is this code?

    Also, please review forum rules.

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: CheckBox state not passing to the sub - Please Help

    What type of checkbox is it?
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    12-11-2012
    Location
    Kansas
    MS-Off Ver
    Excel 2011
    Posts
    12

    Re: CheckBox state not passing to the sub - Please Help

    Not sure what you mean by "type of Check box". I am just trying to control the color of a tab with a checkbox within the worksheet.

  5. #5
    Registered User
    Join Date
    12-11-2012
    Location
    Kansas
    MS-Off Ver
    Excel 2011
    Posts
    12

    Re: CheckBox state not passing to the sub - Please Help

    I can't get the value to be "TRUE"

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: CheckBox state not passing to the sub - Please Help

    Is it a Forms checkbox or an ActiveX checkbox?

  7. #7
    Registered User
    Join Date
    12-11-2012
    Location
    Kansas
    MS-Off Ver
    Excel 2011
    Posts
    12

    Re: CheckBox state not passing to the sub - Please Help

    Its a forms Checkbox

  8. #8
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,705

    Re: CheckBox state not passing to the sub - Please Help

    If it's a Forms checkbox then your code will not work. That code is for an ActiveX checkbox. You have two options. My personal favorite is delete your checkbox then create an ActiveX checkbox and name it CheckBox9. Use the same code.

    Second option is modify your code. Note that you must make it Public and then do Assign Macro for the checkbox to assign it to this code:

    Please Login or Register  to view this content.
    Last edited by 6StringJazzer; 12-11-2012 at 03:02 PM. Reason: was check box 1 in my test case, OP needs 9

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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