+ Reply to Thread
Results 1 to 4 of 4

[SOVLED] Error 1004 "Application Defined or Object Defined Error"

  1. #1
    Registered User
    Join Date
    05-14-2015
    Location
    Atlanta GA
    MS-Off Ver
    2007
    Posts
    16

    [SOVLED] Error 1004 "Application Defined or Object Defined Error"

    Hi, I'm new to writing macros in Excel and I'm trying to write on that iterates through the rows of an excel file until it matches a string, and delete all the rows before the string. Below is my code:

    Please Login or Register  to view this content.
    However, when I run the macro on my test spreadsheet, I get an error on the If statement saying there is an 'object defined error'. What does this mean? Thanks!
    Last edited by gautum123; 05-15-2015 at 09:56 AM.

  2. #2
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Error 1004 "Application Defined or Object Defined Error"

    Please put your code in code tags. Edit your post, highlight the code, then press the # button in the text editor's toolbar.

    Anyway, the error is because Range(i) is not a range. You'd need something like

    Please Login or Register  to view this content.
    Also, you don't want to set i = LR before you loop. If you did that, you'd only go through your Do loop once. You can either move that to before the Else, or just remove that and put an Exit Do before the Else.


    Edit: By the way, here is a MUCH faster approach than iterating through every cell, especally if your search result is hundreds of rows or more down the sheet:

    Please Login or Register  to view this content.
    Last edited by walruseggman; 05-14-2015 at 12:05 PM.

  3. #3
    Registered User
    Join Date
    05-14-2015
    Location
    Atlanta GA
    MS-Off Ver
    2007
    Posts
    16

    Re: Error 1004 "Application Defined or Object Defined Error"

    Oh that makes sense! Thanks so much!

  4. #4
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Error 1004 "Application Defined or Object Defined Error"

    Glad to help. Please mark this thread as SOLVED, and any reputation points (the * in the lower left of the posts) is appreciated.

+ 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. getting error 1004 "Application defined or object defined error
    By The Fly in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-08-2014, 09:39 AM
  2. [SOLVED] Run time error:1004 "Application defined or Object defined error"
    By mvneema in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-07-2014, 09:47 AM
  3. [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
  4. Error When Implementing Code: "1004 - Application-defined or object-defined error"
    By blueblazingdemon in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-10-2013, 11:21 AM
  5. Replies: 1
    Last Post: 05-06-2013, 06:07 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