+ Reply to Thread
Results 1 to 6 of 6

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

Hybrid View

  1. #1
    Registered User
    Join Date
    09-18-2012
    Location
    tx, usa
    MS-Off Ver
    Excel 2010
    Posts
    11

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

    I have attached a macro I found at peltiertech.com for free. It's purpose is to align the secondary axis with the primary. I've tried running it in several workbooks but always get Run-time error '91'. I've tried solutions found on other websites but not solved the issue. Thanks in advance.
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,933

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

    Post a workbook with the macro and sample data included.
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    09-18-2012
    Location
    tx, usa
    MS-Off Ver
    Excel 2010
    Posts
    11

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

    Sorry about that. I have attached a sample workbook.
    Attached Files Attached Files

  4. #4
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,933

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

    The code runs if a chart is selected priorly. Therefore, add, at the top:
        Dim ChartName As String
        On Error GoTo NOCHART:
        ChartName = ActiveChart.Name
    and
    NOCHART:
        If Err.Number <> 0 Then
            MsgBox ("Please select the chart and try again")
            Err.Clear
        End If
    at the bottom.

  5. #5
    Registered User
    Join Date
    09-18-2012
    Location
    tx, usa
    MS-Off Ver
    Excel 2010
    Posts
    11

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

    Thanks protonLeah.

  6. #6
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

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

    @ ppp112

    Welcome to the forum.

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

    Also, as a new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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