+ Reply to Thread
Results 1 to 4 of 4

1004 application defined error

  1. #1
    Forum Contributor
    Join Date
    12-02-2010
    Location
    USA
    MS-Off Ver
    Excel 365 and sometimes excel 2013
    Posts
    172

    1004 application defined error

    hi, i have 2 macros that run fine by themselves, but when I try to combine them into one i get a "run-time error '1004' application-defined or object defined error" and don't know why. the error is in the SetupVariables macro at the line listed below, but it works fine in other macros since it is used to set up the variables. any ideas why i am getting this error?

    Please Login or Register  to view this content.
    the daily_file assignment is flagged in the SetupVariables macro (below), but not the first assignment line for the business plan. if i comment out that daily_run line it flags the next eligibility_file line.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: 1004 application defined error

    Hi there,

    It's difficult to be certain without access to all of your code, but I suspect that the dreaded "not-fully-qualified reference" strikes again!

    In the problem line:

    Please Login or Register  to view this content.
    the code will look for a worksheet called "inputs" in whichever workbook happens to be active when the line is executed, and will generate that error message if it is unable to find such a worksheet.


    To avoid situations like this you should always use fully-qualified references, e.g:

    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.

    Hope this helps - please let me know how you get on.

    Regards,

    Greg M

  3. #3
    Forum Contributor
    Join Date
    12-02-2010
    Location
    USA
    MS-Off Ver
    Excel 365 and sometimes excel 2013
    Posts
    172

    Re: 1004 application defined error

    hi greg, i suspected it was something like that, but still don't understand why it works in other macros even though the same SetupVariables macto is called. however, i did use the fully qualified reference method to reference the file where the SetupVariables refers to without having to fully qualify all the lines and that seems to work. thx again.

  4. #4
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: 1004 application defined error

    Hi again,

    Many thanks for your feedback.

    You're welcome - glad I was able to help.

    As far as:


    but still don't understand why it works in other macros

    is concerned, it all depends on which workbook is active when the routine is activated. Given that your routines open other workbooks, there is no guarantee that the "correct" workbook is active when the routine executes.


    Regards,

    Greg M

+ 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: 5
    Last Post: 08-19-2015, 07:10 PM
  2. 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
  3. 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
  4. Replies: 1
    Last Post: 03-12-2014, 12:42 PM
  5. [SOLVED] Error 1004: Application-defined or object-defined error on Range(Cells(x,y)) syntax
    By winch in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-04-2013, 11:02 AM
  6. Replies: 2
    Last Post: 09-12-2012, 01:01 PM
  7. Replies: 0
    Last Post: 05-14-2012, 11:59 PM

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