+ Reply to Thread
Results 1 to 9 of 9

Run-time Error 1004, delete method of range class failed? (Code included)

  1. #1
    Forum Contributor
    Join Date
    08-29-2017
    Location
    London England
    MS-Off Ver
    2016
    Posts
    194

    Run-time Error 1004, delete method of range class failed? (Code included)

    Hi all,

    I am trying to make this code work, and surprisingly.. it does.

    Only, since I wrote the last section (from "Dim j as Long" onwards), I keep getting an error message, that "delete method of range class failed", but it does delete the rows that I wanted deleted, just pops up this error message. Anyone could help me fix this?
    (I tried it with ActiveSheet.Listobjects, Sheet2.Listobjects, Sheet2.Rows, ActiveSheet.Rows with the Activesheet.Listobjects it does it just pops up the error message the others don't even do it and give the same error.)
    Also it would be nice if I didn't have to write the whole "Wizz Air Hungary Kft." into the If just something like "Wizz*" but that doesn't work for some reason. Pls help!

    Thanks

    Please Login or Register  to view this content.

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Run-time Error 1004, delete method of range class failed? (Code included)

    .Range is what's causing that error to appear.

    Since you are deleting entire row, not just the table's data range. Just use ActiveSheet.Rows(j).Delete

    If you just want to delete table row...
    Please Login or Register  to view this content.
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  3. #3
    Forum Contributor
    Join Date
    08-29-2017
    Location
    London England
    MS-Off Ver
    2016
    Posts
    194

    Re: Run-time Error 1004, delete method of range class failed? (Code included)

    Error 438 object doesn't support this property or method and it doesn't do it now

  4. #4
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Run-time Error 1004, delete method of range class failed? (Code included)

    Oh my bad on ListObject. You need Range argument for that one. Just not EntireRow.

  5. #5
    Forum Contributor
    Join Date
    08-29-2017
    Location
    London England
    MS-Off Ver
    2016
    Posts
    194

    Re: Run-time Error 1004, delete method of range class failed? (Code included)

    It did it, but the 1004 error delete method of range class failed popped up again

  6. #6
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Run-time Error 1004, delete method of range class failed? (Code included)

    Hmm, had no issue on my end. I'd recommend uploading sample workbook. Without it, bit hard to debug as I have no idea how your workbook is set up.

  7. #7
    Forum Contributor
    Join Date
    08-29-2017
    Location
    London England
    MS-Off Ver
    2016
    Posts
    194

    Re: Run-time Error 1004, delete method of range class failed? (Code included)

    So

    The SampleConverter is what I am working on, exact same code in it as posted here.

    ConvertFrom is an excel file that represents the source file that the converter will have to work with. This source file is generated by another software we have
    no control over, and is generated every month in the exact same format, so I thought I make a converter workbook that will format it for us as we need it.

    Just open the convert from, CTRL+* CTRL+C and CTRL+V into the converter (second sheet A1)

    Attached

    Code runs, does what it needs to do, only it pops up the 1004 error code.
    Attached Files Attached Files

  8. #8
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Run-time Error 1004, delete method of range class failed? (Code included)

    Oh, I see the issue now. You are trying to delete the header row.

    Change "To 1..." to "To 2..."
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    08-29-2017
    Location
    London England
    MS-Off Ver
    2016
    Posts
    194

    Re: Run-time Error 1004, delete method of range class failed? (Code included)

    AHH Magic! Very true! Thank you, it works just fine now!

+ 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: 1
    Last Post: 08-08-2016, 04:35 PM
  2. [SOLVED] Run-time error '1004': Delete method of Range class failed
    By Nobo1234 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-14-2016, 03:01 AM
  3. 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
  4. Replies: 4
    Last Post: 11-15-2013, 05:03 PM
  5. VBA Code...error = run time error 1004 autofilter method of range class failed
    By Dariusd7 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-15-2013, 04:49 PM
  6. [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
  7. [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

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