+ Reply to Thread
Results 1 to 14 of 14

Run-time Error '1004': Application-defined or object-defined error

  1. #1
    Registered User
    Join Date
    03-01-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    78

    Run-time Error '1004': Application-defined or object-defined error

    Dear Gurus,

    Run-time Error '1004': Application-defined or object-defined error

    The above-mentioned error keeps popping up when I execute the code below. It was running perfectly fine till I switched the sourceWB workbook and made changes to the code to reflect the change.

    When the error occurs, the following code was highlighted

    lRow = ws1.Cells(Rows.Count, "B").End(xlUp).Row - 2

    Since the change, i could not get the macro to run and it is driving me crazy.
    Hope someone can help to highlight what could be the possible cause of this error.


    Thanks in advance.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Run-time Error '1004': Application-defined or object-defined error

    The problem could be here

    Please Login or Register  to view this content.
    Does sourceWB exist ie "FRBO (Private Apt).xls"

    Does "Sheet1" exist in that workbook
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Run-time Error '1004': Application-defined or object-defined error

    lRow = ws1.Cells(Rows.Count, "B").End(xlUp).Row - 2
    It is highly likely that column B in sheet sourceWB.Sheets("Sheet1") is blank. Since the default value for IRow is 1 and 1 minus 2 is minus 1, that is, IRow is -1. You can't have a minus row.

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Run-time Error '1004': Application-defined or object-defined error

    Please Login or Register  to view this content.

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,936

    Re: Run-time Error '1004': Application-defined or object-defined error

    Your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  6. #6
    Registered User
    Join Date
    03-01-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    78

    Re: Run-time Error '1004': Application-defined or object-defined error

    Hi FDibbins,
    First of all, I apologise for "cross-posting", I am not aware of it's against forum rules.
    Very desperate to find a solution to this error asap.


    To mehmetcik,
    sourceWB "FRBO (Private Apt).xls" exist, and "Sheet1" as well in the workbook.
    It was working fine when sourceWB was another file "Res Source WB.xls", i need to make a switch because it's an updated copy. But after changing it the error pops up.


    To AB33
    Thanks for highlighting the probable cause. sourceWB.Sheets("Sheet1") is filled with data (more than 100 rows of data).


    To jindon
    "lRow = ws1.Cells(ws1.Rows.Count, "B").End(xlUp).Row - 2"
    I tried this as well, to specify where the source is so that there is no ambiguity. But it does not work.

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,936

    Re: Run-time Error '1004': Application-defined or object-defined error

    Please provide the link here, to where you x-posted, and share this link with them too.

  8. #8
    Registered User
    Join Date
    03-01-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    78

    Re: Run-time Error '1004': Application-defined or object-defined error

    Quote Originally Posted by FDibbins View Post
    Please provide the link here, to where you x-posted, and share this link with them too.
    https://www.mrexcel.com/forum/excel-...ned-error.html

  9. #9
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Run-time Error '1004': Application-defined or object-defined error

    My poor guess is then you are working on two different workbooks.

    Set sourceWB = Workbooks("FRBO (Private Apt).xls")
    Set targetWB = Workbooks("ck's database_Residential (updating 01 May 2018).xlsm")
    If the active workbook is not sourceWB when you run the code, you will get an error as the code is unable to find it.

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Run-time Error '1004': Application-defined or object-defined error

    Quote Originally Posted by whoosh View Post
    To jindon
    "lRow = ws1.Cells(ws1.Rows.Count, "B").End(xlUp).Row - 2"
    I tried this as well, to specify where the source is so that there is no ambiguity. But it does not work.
    How is it not working?
    Not working as you expect?

    You said, you are getting "Run-time Error '1004': Application-defined or object-defined error".
    Rows.Count is referring to the ACTVE workbook.
    When .xlsm is active,and try to get the Rows.Count of the version before 2007 .xls, it raise the error because of the version difference.

  11. #11
    Registered User
    Join Date
    03-01-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    78

    Re: Run-time Error '1004': Application-defined or object-defined error

    Yes, I am working on 2 different workbooks. Both are opened when i execute the code.

    I saved the sourceWB as macro-enabled format - FRBO (Private Apt).xls to FRBO (Private Apt).xlsm, when i run the code no error but nothing copied!

  12. #12
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Run-time Error '1004': Application-defined or object-defined error

    That's a different problem from what you asked.

  13. #13
    Registered User
    Join Date
    03-01-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    78

    Re: Run-time Error '1004': Application-defined or object-defined error

    Quote Originally Posted by jindon View Post
    That's a different problem from what you asked.
    Hi jindon,

    I am trying various options to see if i can get it to work/ to find the cause to the problem.
    The latest development is as stated in my previous post, saving xls to xlsm format, no errors but nothing copied as well.
    Saving to xlsm format is not viable in the long run, because I'm getting the source in xls format for updating.

  14. #14
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Run-time Error '1004': Application-defined or object-defined error

    Then you need to clearly state what your actual problem is.

    No body can see inside your brain.

+ 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. excel macro run time error '1004'- Application defined or object defined error
    By kmadan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-16-2014, 09:51 AM
  5. Replies: 1
    Last Post: 03-12-2014, 12:42 PM
  6. [SOLVED] Run time error 1004 Application-Defined or Object-Defined Error - Placing data into next e
    By michelle 1 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 01-27-2014, 12:57 PM
  7. [SOLVED] run-time error '1004' application-defined or object-defined error - Excel 2007
    By kaurka in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-06-2012, 02:46 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