+ Reply to Thread
Results 1 to 7 of 7

VBA code to disable check boxes based on values

  1. #1
    Registered User
    Join Date
    04-19-2013
    Location
    Perth, WA
    MS-Off Ver
    Excel 2010
    Posts
    6

    VBA code to disable check boxes based on values

    Hi,

    I am looking for a VBA code that when the sheet is activated, disables check boxes based on a conditional values.

    I have used form check boxes (Check Box 36 to Check box 60) and have a column of true/false vales (Y3:Y27).

    What I would like is when the sheet is selected, it loops through all the check boxes and disables them if the appropriate value is false.

    Thanks,

    Chris

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,483

    Re: VBA code to disable check boxes based on values

    You are missing a very important part of your question.
    That is
    disables them if the appropriate value is false.
    What do you mean by this?

  3. #3
    Registered User
    Join Date
    04-19-2013
    Location
    Perth, WA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: VBA code to disable check boxes based on values

    Dave,

    What I mean is for each of the check boxes, there is a corresponding value in column y that determines whether the check box is to be enabled or disabled based on other conditions.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: VBA code to disable check boxes based on values

    Hello Chris,

    Here is a macro that will run each time the worksheet is activated.

    To add the Macro
    1. Copy the macro code
    2. Select the worksheet the check boxes are on.
    3. Right Click the Tab and select View Code....
    4. Paste the macro code and save the changes

    Please Login or Register  to view this content.
    Last edited by Leith Ross; 04-22-2013 at 11:41 PM.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  5. #5
    Registered User
    Join Date
    04-19-2013
    Location
    Perth, WA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: VBA code to disable check boxes based on values

    Leith,

    Thanks for the code, however, when I select the sheet I get the following error code: Run-time error '1004' Unable to get the CheckBoxes property of the Worksheet class.

    When I debug it highlights

    Please Login or Register  to view this content.
    I just changed the code to the following and it now works.

    Please Login or Register  to view this content.
    Thanks again

    Chris
    Last edited by Chris Shepherd; 04-23-2013 at 12:46 AM.

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: VBA code to disable check boxes based on values

    Hello Chris,

    Sorry, I forgot to add a space after "Box". The line should be...
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    04-19-2013
    Location
    Perth, WA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: VBA code to disable check boxes based on values

    Leith,

    I just figured it out too

    Chris

+ 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