+ Reply to Thread
Results 1 to 7 of 7

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

  1. #1
    Registered User
    Join Date
    11-30-2010
    Location
    Toronto
    MS-Off Ver
    Excel 2007
    Posts
    8

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

    Hi, I have very little idea of how to program in VBA but I've managed so far by consulting internet forums to obtain the following code to do what I need, but I am getting an error and I don't know what is wrong? Here is the code:

    Please Login or Register  to view this content.
    Last edited by VBAn00b; 12-01-2010 at 02:29 PM.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,025

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

    What is the code supposed to do? I don't see what the variables are for.
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

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

    Like so:
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Registered User
    Join Date
    11-30-2010
    Location
    Toronto
    MS-Off Ver
    Excel 2007
    Posts
    8

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

    Well, at the beginning I kept getting Run-time error: '1004': Application-defined or object-defined error. So I thought it was because of undefined variables..

    But when I tried your code, it gave me the error code '1004' again..

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

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

    I didn't bother to check your formulas, I just assumed you recorded a macro to get those. My bad.

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    11-30-2010
    Location
    Toronto
    MS-Off Ver
    Excel 2007
    Posts
    8

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

    Ahhh yes, it works now.. thank you so much!

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

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

    If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

+ 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