+ Reply to Thread
Results 1 to 4 of 4

Run-time error '1004': Delete method of Range class failed

  1. #1
    Registered User
    Join Date
    06-10-2016
    Location
    Finland
    MS-Off Ver
    2010
    Posts
    3

    Run-time error '1004': Delete method of Range class failed

    Hey,

    This is my first post here and I apogolize already if I'm doing something wrong.

    What I'm doing:
    I'm copying big loads of data from place A to place B. All the data doesn't get copied (ex: file size is too big, name is too long and other problems). I need to check afterwards which files didn't get copied and copy them manually. I decided to do the checking with excel (the guy before me just checked them manually and it took hours). I export both files to excel and compare the names of the files and made a macro to do it.

    The macro:
    The macro compares every file name (cell) from the copied files to the original file names. Every time it finds a match, it deletes the match from the original file name list. It leaves behind none copied files. The macro works pretty well on smaller data (~1-3000) rows on both lists but when I have more rows it starts to says "Run-time error '1004': Delete method of Range class failed".

    If there's an easier way to do the comparing please let me know (find duplicates doesn't work. example: if there's one file named "numbers" in the first list and 3 files with the same names (numbers) in the second list, it deletes all of them. It should delete only one since there was only one file named that way in the first list). I'm not that experienced with Excel but I'm learning. I'm using Excel2010.

    Please Login or Register  to view this content.

    All help is appreciated!
    Last edited by Nobo1234; 06-10-2016 at 05:00 AM.

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Run-time error '1004': Delete method of Range class failed

    If you're deleting items, then work backwards through the list - saves trying to account for those deleted row/items.

    Please Login or Register  to view this content.
    Not saying that is your problem, but is something you should do in any case.

  3. #3
    Registered User
    Join Date
    06-10-2016
    Location
    Finland
    MS-Off Ver
    2010
    Posts
    3

    Re: Run-time error '1004': Delete method of Range class failed

    Thank you very much for your answer. I'll use that to make it work faster.

  4. #4
    Registered User
    Join Date
    06-10-2016
    Location
    Finland
    MS-Off Ver
    2010
    Posts
    3

    Re: Run-time error '1004': Delete method of Range class failed

    In case someone stumbles in the same problem a simple "Exit for" under iCtr = iCtr +1 seems to do the trick. The code was also in another way a bit bugged and it solves the bug too.

+ 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. Run-time error '1004': PasteSpecial method of Range class failed
    By jaghuar in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-14-2015, 07:35 PM
  2. Run-time error '1004': Delete method of Range class failed
    By Lozza1234 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-17-2014, 04:56 PM
  3. Replies: 1
    Last Post: 01-07-2014, 01:08 AM
  4. Run-Time Error '1004' AutoFill method of Range class Failed
    By RS944 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-15-2013, 11:37 AM
  5. [SOLVED] Run-time error '1004' ; Delete method of Range Class failed
    By Adam1987 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-14-2012, 06:43 AM
  6. [SOLVED] Delete method of range class failed - run time error 1004
    By plasma33 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-28-2012, 07:37 AM
  7. Run-time error '1004': Select Method of Range Class Failed
    By hazza147 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-22-2010, 07:19 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