+ Reply to Thread
Results 1 to 14 of 14

Run-time 91 error

  1. #1
    Registered User
    Join Date
    04-30-2021
    Location
    Canada
    MS-Off Ver
    365
    Posts
    12

    Run-time 91 error

    Hello,

    I am having an issue with a section of an inventory Excel spreadsheet and have an issue with only 1 sheet in a series of automated processes. I keep recieveing a run-time error 91 on this section of code:

    Please Login or Register  to view this content.
    The debugger gives me the error on this specific line (4th from the top):

    Please Login or Register  to view this content.
    Any help on how to solve this issue would be greatly appreciated.

    Thanks in advance,

    Alex
    Attached Images Attached Images
    Last edited by ABourdages; 04-30-2021 at 09:56 AM.

  2. #2
    Registered User
    Join Date
    07-15-2013
    Location
    U.S.
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Run-time 91 error

    Is this trying to clear an auto filter in a table? Or just a range NOT in a table?
    Last edited by mcduderz; 04-30-2021 at 10:07 AM.

  3. #3
    Registered User
    Join Date
    04-30-2021
    Location
    Canada
    MS-Off Ver
    365
    Posts
    12

    Re: Run-time 91 error

    I'm not entirely sure. I've just (for lack of a better word) 'inherited' this work tool from my predecessor who has since left the company. What I know is that there are a bunch of sheets, one for each warehouse we use and that these macros are supposed to sort the data and render printable versions. I don't know if that helps...

  4. #4
    Registered User
    Join Date
    07-15-2013
    Location
    U.S.
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Run-time 91 error

    Attachment 730611

    This image is a Table, where there are headers and arrows next to them. Like in the top left cell you see "Day of Week" then an arrow box next to it. If you don't see Headers with arrow boxes then it's NOT a table.

  5. #5
    Registered User
    Join Date
    04-30-2021
    Location
    Canada
    MS-Off Ver
    365
    Posts
    12

    Re: Run-time 91 error

    Here is a print screen of the sheet in question, if that helps

    Attachment 730612

  6. #6
    Registered User
    Join Date
    04-30-2021
    Location
    Canada
    MS-Off Ver
    365
    Posts
    12

    Re: Run-time 91 error

    According to your description, its a table

  7. #7
    Registered User
    Join Date
    07-15-2013
    Location
    U.S.
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Run-time 91 error

    There's bad code there. the line is actually stopping on:

    Selection.AutoFilter

    Need more time.

  8. #8
    Registered User
    Join Date
    04-30-2021
    Location
    Canada
    MS-Off Ver
    365
    Posts
    12

    Re: Run-time 91 error

    No problem, take the time you need. And thank you for your help, its much appreciated!

  9. #9
    Registered User
    Join Date
    07-15-2013
    Location
    U.S.
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Run-time 91 error

    Quick fix is to Comment out 4 lines of code that seem broken / not applicable that causes it to stop
    How to comment something to be ignored in code, just add a ' before text:
    'This is a comment
    This is not a comment

    The 4 lines to comment out are:
    'Selection.AutoFilter
    and the 3 lines that say:
    '.Apply

  10. #10
    Registered User
    Join Date
    04-30-2021
    Location
    Canada
    MS-Off Ver
    365
    Posts
    12

    Re: Run-time 91 error

    I tried it, but I got the same error code. Here is a screenshot in case I did it wrong:

    Attachment 730621

  11. #11
    Registered User
    Join Date
    07-15-2013
    Location
    U.S.
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Run-time 91 error

    The image isn't working so I can't see. I'm thinking that you have a different version of excel / office than I do.

    If you want to sort manually, you can. (You might already know how to do it) Click the arrow box next to a header and it gives you options to sort.

    I'm sorry I couldn't help much. Anyone else wanna try helping?

  12. #12
    Registered User
    Join Date
    04-30-2021
    Location
    Canada
    MS-Off Ver
    365
    Posts
    12

    Re: Run-time 91 error

    Thanks anyway, I really appreciate the effort you put in!

  13. #13
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: Run-time 91 error

    Try replacing this line
    Please Login or Register  to view this content.
    with
    Please Login or Register  to view this content.

  14. #14
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    365 32bit Win
    Posts
    1,941

    Re: Run-time 91 error

    Perhaps there is no autofilter when it reaches that line.
    Maybe actively remove AutoFilter before applying, then there's also no need to clear the sort. It'll also ensure that the filter is reapplied to the correct row.

    Please Login or Register  to view this content.

+ 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. [SOLVED] Error message: Run-Time error '1004 '; application-defined or object-defined error
    By Davasu in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-23-2015, 06:52 AM
  2. Replies: 1
    Last Post: 10-22-2015, 05:50 AM
  3. VBA ERROR: run time error 1004: Application-defined or Object-defined error in excel 2013
    By AnanthKrishna in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-13-2015, 06:16 AM
  4. Cannot Publish Excel Pivot Chart - Run Time Error
    By crisb184 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-11-2013, 07:04 AM
  5. [SOLVED] Error " Run-time error '1004': application defined or object defined error
    By lengwer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-11-2013, 07:26 AM
  6. run-time error ;2147023179 (800706b5) time automation error interface unknown
    By karthik72 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-02-2012, 09:31 AM
  7. Error "run-time Error '1004': General Odbc Error
    By D4WNO77 in forum Access Tables & Databases
    Replies: 2
    Last Post: 07-16-2012, 09:55 AM

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