+ Reply to Thread
Results 1 to 9 of 9

Runtime Error '91' Object variable or With Block variable not set.

  1. #1
    Registered User
    Join Date
    02-09-2007
    Posts
    39

    Runtime Error '91' Object variable or With Block variable not set.

    Hello,

    Thanks for helping.

    I'm getting a
    Runtime Error '91'
    Object variable or With Block variable not set.
    when I run a button that creates a pie chart from a set of data:

    When I hit debug, this is what highlights:
    ActiveChart.ChartType = xlPie

    Please Login or Register  to view this content.
    Do you have any idea what is wrong?

    Thank you.
    Last edited by pink; 02-17-2009 at 03:29 PM.

  2. #2
    Valued Forum Contributor Richard Schollar's Avatar
    Join Date
    05-23-2006
    Location
    Hampshire UK
    MS-Off Ver
    Excel 2002
    Posts
    1,264

    Re: Runtime Error '91' Object variable or With Block variable not set.

    I may be wrong here as I rarely do anything with charts but sometimes the order of code can cause problems when manipulating charts so I suggest you change the two lines around:

    Please Login or Register  to view this content.
    Richard Schollar
    Microsoft MVP - Excel

  3. #3
    Registered User
    Join Date
    02-09-2007
    Posts
    39

    Re: Runtime Error '91' Object variable or With Block variable not set.

    Sorry about that. Edited.
    Last edited by pink; 02-15-2009 at 03:30 PM.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Runtime Error '91' Object variable or With Block variable not set.

    Pink,

    Please take a few minutes to read the Forum Rules, and then edit your post to wrap your code with Code Tags.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Registered User
    Join Date
    02-09-2007
    Posts
    39

    Re: Runtime Error '91' Object variable or With Block variable not set.

    Thank you, Richard.

    I tried what you suggested, and the error still exists, and instead of the

    Please Login or Register  to view this content.
    being highlighted, it is the

    Please Login or Register  to view this content.
    Hmm.

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,468

    Re: Runtime Error '91' Object variable or With Block variable not set.

    It may help if you posted example workbook as your original code worked fine for my test data.
    Cheers
    Andy
    www.andypope.info

  7. #7
    Registered User
    Join Date
    02-09-2007
    Posts
    39

    Re: Runtime Error '91' Object variable or With Block variable not set.

    Quote Originally Posted by Andy Pope View Post
    It may help if you posted example workbook as your original code worked fine for my test data.
    Sure, thanks.

    I have to mention that this works for me as well ( Excel 2003 ), but I have a friend who gets this problem when she uses it (2007)

    I've attached the worksheet. It is the macro for "Chart Earnings" that doesn't work properly for her, the other two buttons work. And they have virtually the same code...
    Attached Files Attached Files

  8. #8
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,468

    Re: Runtime Error '91' Object variable or With Block variable not set.

    The code fails because no chart is added when the selected range includes the Name cell.

    This fails but does not raise an error
    Please Login or Register  to view this content.
    try this revision
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    02-09-2007
    Posts
    39

    Re: Runtime Error '91' Object variable or With Block variable not set.

    That will probably do it, thank you.

    I'll have my friend run it and will post back with results shortly.

    Thank you.

    edit: it works perfectly. Thank you very much.

    Solved.
    Last edited by pink; 02-17-2009 at 03:28 PM.

+ 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