+ Reply to Thread
Results 1 to 6 of 6

"Autofill method of RangeClass failed" -- when I have en empty list! :(

  1. #1
    Registered User
    Join Date
    08-03-2017
    Location
    Toronto
    MS-Off Ver
    2013
    Posts
    4

    Lightbulb "Autofill method of RangeClass failed" -- when I have en empty list! :(

    I was making a code to filter/sort several sheets of data, and then apply formulas (in the H column and I column) to each (filtered) piece of data.
    When there is data that exists from the filtered list, the code works fine. However, if NO data makes it through my filter, then I get the error: "Autofill method of RangeClass failed", because from looking at my code, it tries to count the rows in "A" and then copy the formula in "H" all the way down... but if there aren't any rows, I assume it gets confused? It's important because when there's this error it stops the rest of my subsequent codes from working! Please help!

    I put two parts of my code below. They're essentially the same, just for two different sheets with data. The first part for "Line2" works fine because there is data, but the one for "Line3" messes up at the bolded section: Range("H2").AutoFill Destination:=Range("H2:H" & Cells(Rows.Count, "A").End(xlUp).Row

    How can I apply some kind of "if" statement for if there is no data shown?
    Keep in mind that the list still exists on the page, and jumps from "A2" to "A139" for example, because all of the data is still there just hidden because of the filter. Hence I can't really use if A3="" , for example, because there technically is data in A3 still.


    Please Login or Register  to view this content.
    Attached Images Attached Images
    Last edited by clvander; 08-08-2017 at 11:52 AM.

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: "Autofill method of RangeClass failed" -- when I have en empty list! :(

    Maybe:

    Please Login or Register  to view this content.
    BTW - you should put code tags around your code: just highlight your code and hit the #
    Last edited by xladept; 08-03-2017 at 12:55 PM.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    08-03-2017
    Location
    Toronto
    MS-Off Ver
    2013
    Posts
    4

    Re: "Autofill method of RangeClass failed" -- when I have en empty list! :(

    Hey! Thanks so much for the tips! I'm a bit new, hahah.
    Because of some of the purposes of my code I shifted it around a bit, and called another code within, but ultimately did use your idea and method to fix the problem.
    I love how you used the "r<>2" logic; works like a charm.

    Please Login or Register  to view this content.
    Cheers!

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: "Autofill method of RangeClass failed" -- when I have en empty list! :(

    You're welcome and thanks for the rep!

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

    And - you should put code tags in the first post

  5. #5
    Registered User
    Join Date
    08-03-2017
    Location
    Toronto
    MS-Off Ver
    2013
    Posts
    4

    Re: "Autofill method of RangeClass failed" -- when I have en empty list! :(

    Done and done! You're great.
    Have a nice day!

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: "Autofill method of RangeClass failed" -- when I have en empty list! :(

    Excellent and well done!

+ 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. Method "Add" of object "ChartObjects" failed
    By praftery in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-25-2016, 06:45 AM
  2. Method "AddPicture" of object "InlineShapes" failed - but only one 1 computer
    By Alves76 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-20-2013, 10:49 AM
  3. [SOLVED] Receiving a "Method 'Range' of object'_Global' failed" error
    By aloha31 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-17-2013, 06:51 PM
  4. [SOLVED] Very small AutoFill macro showing "AutoFill methode of range class failed" why ?
    By nur2544 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-28-2013, 10:21 PM
  5. "The "sheets" method from the "_Global" object have failed."
    By mankit87 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-08-2011, 08:53 AM
  6. Runtime Error "1004" Autofill Method of range class failed
    By DonKarlos in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-15-2009, 07:44 PM
  7. What is Error "Method "Paste" of object "_Worksheet" failed?
    By vat in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-17-2006, 04:10 PM

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