+ Reply to Thread
Results 1 to 3 of 3

Run-time error '91': Object variable or With block variable not set

  1. #1
    Registered User
    Join Date
    08-25-2010
    Location
    Boston, MA
    MS-Off Ver
    Excel 2007
    Posts
    23

    Run-time error '91': Object variable or With block variable not set

    Hello -

    My macro's objective is to determine if any 1 of 21 string values exists in a list passed to it. If yes, set the cell to the right to '1'.


    Using the code below, I am getting a Run Time error 91

    Please Login or Register  to view this content.

    I have tried various iterations.


    Also, I have written the first 'Find' statement using the 'Products' object, but not the rest of the 'Find' statements. Is one way better than the other?

    The sheet used is 'Register'. The macro is 'test'.
    Attached Files Attached Files
    Last edited by Snoopy2010; 08-31-2010 at 05:03 PM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Run-time error '91': Object variable or With block variable not set

    Hi,

    Why not simplify things and use standard Excel functions. See the attached - Column U.
    Just copy column U and paste back to C as values.
    If you want to automate this then get the macro to do the copy and paste.

    That would be far simpler and quicker than a long macro.

    HTH
    Attached Files Attached Files
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    08-25-2010
    Location
    Boston, MA
    MS-Off Ver
    Excel 2007
    Posts
    23

    Smile Re: Run-time error '91': Object variable or With block variable not set

    This is very helpful. This essentially is what I started out doing, only with find & vlookup. Wasn't sure of syntax.

    Some more information - The 'products' range will vary in length with each use. This entire macro is part of a much larger & more complex task. My orig attempt was to define 2 ranges (the products one, and the 21 I need to look for) and to use your approach to look for the products in the 21, rather than the 21 in the products.

    With your help, I am very close. I have two remaining tasks (1 for sure, 1 'nice to have')

    Need for sure: have this sub-task loop through the entire 'products' list for any run it encounters (max # products is more like 350. My orig 50 was to get the code right. My current 500 is where I want to set it).

    Nice to have: when sub-task reaches end of products list (as indicated by null cell in products range) to not continue until row 500.

    I am attaching my updated doc. I have done nothing to the macro previously supplied. I have added a second tab - SYSTABLES. This mirrors the full task.

    Using your modification, I now have the following:

    Please Login or Register  to view this content.
    Note: I have removed all reference to the 'products' range. Suffice it to say, it = ("B13:B500").

    Might you be able to suggest anything? Thanks again!
    Attached Files Attached Files

+ 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