+ Reply to Thread
Results 1 to 5 of 5

Run-time Error 91 Object Variable or With Block...

  1. #1
    Registered User
    Join Date
    02-18-2005
    Posts
    44

    Run-time Error 91 Object Variable or With Block...

    I have upgrade to Excel 2016 and the VBA code we have been using for 20+ years is having issues. One piece of code that is giving me the Runtime Error 91 is the following. Any help to resolve would be appreciated.

    Sub Chart2Update()
    FormatChart2

    ActiveSheet.Unprotect ("rm2000")
    ChangeAuto:

    ActiveChart.Axes(xlValue).Select --The debug brings me to this line as being the issue.
    With ActiveChart.Axes(xlValue)
    .MinimumScaleIsAuto = True
    .MaximumScaleIsAuto = True
    .MinorUnitIsAuto = True
    .MajorUnitIsAuto = True
    .Crosses = xlAutomatic
    .ReversePlotOrder = False
    .ScaleType = xlLinear
    .DisplayUnit = xlNone
    End With
    ActiveSheet.Protect ("rm2000")
    FormatChart1PC
    End Sub

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,453

    Re: Run-time Error 91 Object Variable or With Block...

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)

  3. #3
    Registered User
    Join Date
    02-18-2005
    Posts
    44

    Re: Run-time Error 91 Object Variable or With Block...

    Sorry but this is an exact copy from my VBA code. Not sure what more I can add???

  4. #4
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,453

    Re: Run-time Error 91 Object Variable or With Block...

    Please read my post entirely and add code tags as described. Thanks

  5. #5
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,453

    Re: Run-time Error 91 Object Variable or With Block...

    Administrative note
    Also,please update your profile as necessary to properly reflect the exact version(s) of Excel your question relates to. Members tailor answers based on your Excel version. Your profile does not indicate your version.
    Thanks

+ 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. Replies: 12
    Last Post: 12-28-2019, 12:29 PM
  2. [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
  3. [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
  4. Replies: 0
    Last Post: 04-16-2013, 07:15 AM
  5. Replies: 6
    Last Post: 12-21-2012, 08:03 AM
  6. Replies: 1
    Last Post: 09-25-2012, 08:03 PM
  7. [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

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