+ Reply to Thread
Results 1 to 13 of 13

Updating Checkbox - Run-time Error 91 - Object variable or With block variable not set

  1. #1
    Registered User
    Join Date
    12-27-2012
    Location
    Kingston, Jamaica
    MS-Off Ver
    Excel 2007
    Posts
    30

    Updating Checkbox - Run-time Error 91 - Object variable or With block variable not set

    Hey,

    I have been trying to ensure that one check box is ticked across a row. Each time I select the check box I receive the error "Run-time error 91 - Object variable or With block variable not set".. Please see code below
    Please Login or Register  to view this content.
    Any help will be appreciated.
    Nika

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

    Re: Updating Checkbox - Run-time Error 91 - Object variable or With block variable not set

    Do not declare the checkboxes. The fact that they exist is enough to reference them in your code. If you declare variables with the same names they will hide the actual checkboxes. Delete this
    Please Login or Register  to view this content.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,410

    Re: Updating Checkbox - Run-time Error 91 - Object variable or With block variable not set

    Why are you setting CheckBox11 equal to itself, does the worksheet exist, are all the checkboxes on the sheet ?

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,763

    Re: Updating Checkbox - Run-time Error 91 - Object variable or With block variable not set

    I looked at your code again. You should be using option buttons instead of checkboxes then you don't need any of this code.

  5. #5
    Registered User
    Join Date
    12-27-2012
    Location
    Kingston, Jamaica
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: Updating Checkbox - Run-time Error 91 - Object variable or With block variable not set

    When I do not declare the variables I get a compile error message "Variable not defined"

  6. #6
    Registered User
    Join Date
    12-27-2012
    Location
    Kingston, Jamaica
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: Updating Checkbox - Run-time Error 91 - Object variable or With block variable not set

    I have attached the file for you to have a look. I was just trying the code with the first set of checkboxes and wanted to see if it worked. The user must check only on of the three in that row. This is a form that has been in use and I wanted to improve. If the option boxes would be better I will change as well. Just trying to improve the sheet before they start the new year.
    Thanks for all the help.
    Nika
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    12-27-2012
    Location
    Kingston, Jamaica
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: Updating Checkbox - Run-time Error 91 - Object variable or With block variable not set

    I want the ticks to be row specific and when I use the option buttons I can only select for the entire group. I tried by assigning the option button to the another cell for that row but it didn't work.
    Nika

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

    Re: Updating Checkbox - Run-time Error 91 - Object variable or With block variable not set

    You would create three option buttons for each row. If you use Forms controls you have to put each group of three into a Group Box. If you use ActiveX then you would set the Group property to be the same for all three.

    Frankly I think using this many controls is a error-prone to create and maintain, even though it's kind of cool for the user.

    Here is an example where you just click directly on the cell itself. I did it down to row 39. The corresponding code is in the sheet module.
    Attached Files Attached Files

  9. #9
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,410

    Re: Updating Checkbox - Run-time Error 91 - Object variable or With block variable not set

    O.M.G. not another case of merged cells.!!!!!!!!!!!!

  10. #10
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,763

    Re: Updating Checkbox - Run-time Error 91 - Object variable or With block variable not set

    Quote Originally Posted by torachan View Post
    O.M.G. not another case of merged cells.!!!!!!!!!!!!
    Not helpful and not related to the question.

  11. #11
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,410

    Re: Updating Checkbox - Run-time Error 91 - Object variable or With block variable not set

    Always look at a total project and anticipate the potential for problems.
    Pointless solving problems one by one only to be met by the insurmountable further down the line.

  12. #12
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,763

    Re: Updating Checkbox - Run-time Error 91 - Object variable or With block variable not set

    Quote Originally Posted by torachan View Post
    Always look at a total project and anticipate the potential for problems.
    Pointless solving problems one by one only to be met by the insurmountable further down the line.
    Do you have advice specific to this question that will help solve it?

  13. #13
    Registered User
    Join Date
    12-27-2012
    Location
    Kingston, Jamaica
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: Updating Checkbox - Run-time Error 91 - Object variable or With block variable not set

    Thanks for the assistance. I will use your suggestions because this was a form being used and based on numerous issues they wanted improvement. The main problem was the check boxes.

+ 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. [SOLVED] Run time error '91' object variable/with block variable not set when using Find
    By lynnsong986 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-24-2019, 08:33 AM
  2. [SOLVED] Run-time error '91': Object variable or With block variable not set when closing userform
    By bishoposiris in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-10-2016, 08:59 AM
  3. Replies: 0
    Last Post: 04-16-2013, 07:15 AM
  4. Replies: 6
    Last Post: 12-21-2012, 08:03 AM
  5. Replies: 1
    Last Post: 09-25-2012, 08:03 PM
  6. [SOLVED] Intermittent Run-time Error 91: Object Variable or With Block variable not set
    By fraanchtoast in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 08-29-2012, 10:11 AM
  7. Run Time Error 91, Object Variable or With Block Variable not set
    By undergraduate in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-12-2011, 02:08 PM

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