+ Reply to Thread
Results 1 to 4 of 4

How to avoid a Run-time error '91' error

  1. #1
    Valued Forum Contributor
    Join Date
    03-17-2007
    Location
    Michigan
    MS-Off Ver
    Excel 2016
    Posts
    951

    How to avoid a Run-time error '91' error

    I've been using the following code for sometime without any problems, but as of late I have been getting these error -debug windows that indicate a "Run-time error '91': Object variable or with block variable not set" message. It has been frustrating to say the least and I can't understand why it is occurring after a couple of years of no issues. I can't seem to see anything wrong with the coding. I've verified the column count to be correct as well and should be 64. Any suggestions would be greatly appreciated.

    Please Login or Register  to view this content.
    Thanks for looking at this.
    Last edited by lilsnoop; 08-06-2011 at 07:31 PM.

  2. #2
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    2003, 2007, 2010, 2013
    Posts
    1,252

    Re: How to avoid a Run-time error '91' error

    Hi,

    It's very likely that you are seeing that error because it wasn't able to find the combobox value in the range. You can defensively code for that possibility like this:

    Please Login or Register  to view this content.
    I also recommend that you have a look at the Range.Find topic in the VBA helpfile. It has some important notes: you should include more arguments in your code (other than "What") to ensure that unwanted settings from the previous search are overridden. The helpfile tells you which ones as stored from the previous search.
    Hope that helps,

    Colin

    RAD Excel Blog

  3. #3
    Valued Forum Contributor
    Join Date
    03-17-2007
    Location
    Michigan
    MS-Off Ver
    Excel 2016
    Posts
    951

    Re: How to avoid a Run-time error '91' error

    Thanks Colin! The code you provided has stopped the debugging error which I'm grateful for, but the code now seems to expand one additional column over. As a further explanation, Column "BK" is a city name, Column "BL" represents primary zip codes for the affiliated City & Column "BM" is a listing of secondary zip codes for certain cities as it is applicable. Column "BL" is the 64th column as reflected in the code. Now for some reason information displayed in Column "BN" is becoming visible too, which per our coding shouldn't be happening. I hope that makes sense. I do have a sample workbook attached from an earlier post regarding preventing duplicate entries from a userform. Thanks again for any/all input! I will also checkout the vba helpfile you referred to!

  4. #4
    Valued Forum Contributor
    Join Date
    03-17-2007
    Location
    Michigan
    MS-Off Ver
    Excel 2016
    Posts
    951

    Re: How to avoid a Run-time error '91' error

    Hey Colin, I just moved the data from column BN so that whole column is now empty and that has resolved the most recent issue of adding data. Thanks so much for you input & help!! Greatly appreciated!

+ 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