+ Reply to Thread
Results 1 to 15 of 15

Run Type Error 424: Macro to load data from a different workbook

  1. #1
    Registered User
    Join Date
    12-30-2013
    Location
    Lenexa, Kansas
    MS-Off Ver
    Excel 2010
    Posts
    9

    Run Type Error 424: Macro to load data from a different workbook

    Greetings,
    I am new to this forum. I have a macro I've been working on in which I am trying to load a data range from another (unopened) workbook. As my title alludes to, I keep getting error code 424, Object Required. Not sure how to resolve this. Any help would be greatly appreciated.

    The open file and tab I am working on is FH4A Appraisal and the workbook I am trying to load data from is entered as a url path in FH4A Appraisal and is opened with the copyaddress function.
    My code is below and the line the error is happening on has ** after it.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by SGraber; 12-30-2013 at 03:22 PM.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Run Type Error 424: Macro to load data from a different workbook

    What exactly is copyaddress when you get the error?

    Do you actually have a function caled copyaddress?


    PS Can you add code tags?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    12-30-2013
    Location
    Lenexa, Kansas
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Run Type Error 424: Macro to load data from a different workbook

    Hi Norie,
    I'm actually not completely sure what the copyaddress function does. I pulled that code from another macro. It worked for me on a different macro, but isn't on this one for some reason. I believe what it does is look at the url path I designated within the spreadsheet and then copies and opens that file specified there; but I could be wrong about that.

    How do I add code tags?

  4. #4
    Registered User
    Join Date
    12-30-2013
    Location
    Lenexa, Kansas
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Run Type Error 424: Macro to load data from a different workbook

    I think I just figured out how to add those code tags

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Run Type Error 424: Macro to load data from a different workbook

    Is copyaddress definitely a function?

    I'm asking because you don't assign a value to a function as you appear to be doing here.
    Please Login or Register  to view this content.
    That looks more like copyaddress is being treated as a variable, perhaps for the filename/URL of the workbook to open.

    If you click the hyperlink in my signature or in my last post you should find out how to use code tags.

  6. #6
    Registered User
    Join Date
    12-30-2013
    Location
    Lenexa, Kansas
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Run Type Error 424: Macro to load data from a different workbook

    I don't know that copyaddress is definately a function. Just guessing, and probably guessed wrong
    Since I can manually update the filename/url path would that show copyaddress as a variable? Changing that url is part of the usefulness of this macro. That way we can access multiple reports. So if it is a variable, do I need to define it in a different way?

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Run Type Error 424: Macro to load data from a different workbook

    Can you upload an example workbook with the code?

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

  8. #8
    Registered User
    Join Date
    12-30-2013
    Location
    Lenexa, Kansas
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Run Type Error 424: Macro to load data from a different workbook

    Just uploaded the 2 relavant files. I changed the sensitive data, but it shouldn't affect the code at all.

  9. #9
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Run Type Error 424: Macro to load data from a different workbook

    There's no attachments in your post.

    Where did you upload them?

  10. #10
    Registered User
    Join Date
    12-30-2013
    Location
    Lenexa, Kansas
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Run Type Error 424: Macro to load data from a different workbook

    I attached the files to my original post.

  11. #11
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Run Type Error 424: Macro to load data from a different workbook

    Oops, I've been a bit thick.

    The problem is that it should be Workbooks.Open not Workbook.Open.

    If you change that you'll also find another problem, merged cells.

    The named range 'fh4aAppraisalPath' covers the merged cells D8:I8, so Range("fh4aAppraisalPath") will return an array of values from those cells.

    To only get the value you can use this.
    Please Login or Register  to view this content.
    So the start of the code would look like this.
    Please Login or Register  to view this content.
    Or if you wanted to tidy things up a bit.
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    12-30-2013
    Location
    Lenexa, Kansas
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Run Type Error 424: Macro to load data from a different workbook

    Very Nice! We also just discovered that those merged cells were causing an issue. I'll have to check out your clean version of the code, but those two issues solved it. Seperate question, do you happen to know why it's important to define variables up front? I see a lot of people encouraging that by using of Dim but I've never (except for this macro) used Dim in my code before and also never had issues. Does not defining variables cause issues in larger/more complex macros?

  13. #13
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Run Type Error 424: Macro to load data from a different workbook

    You should always declare your variables, especially if you are working with large/complex code.

    I've seen many examples, one recently actually, where someone has either not declared or incorrectly declared variables in large routines and found out the code didn't work as expected.

    A lot of times all that needs fixed is a few variable declarations to get everything up and running.

    Here's a little more about variable declaration.

  14. #14
    Registered User
    Join Date
    12-30-2013
    Location
    Lenexa, Kansas
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Run Type Error 424: Macro to load data from a different workbook

    Thanks again, I'll check out that link.

  15. #15
    Registered User
    Join Date
    12-30-2013
    Location
    Lenexa, Kansas
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Run Type Error 424: Macro to load data from a different workbook

    How do I show this as solved? Is there an option somewhere?

+ 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. load innerthml error in macro
    By paranidharan in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-30-2012, 02:12 PM
  2. type mismatch with chart data load
    By shadowphile in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 02-22-2010, 07:06 AM
  3. auto load data from one workbook to another
    By jmw in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-22-2006, 09:25 AM
  4. removal of circular reference error on excel workbook load
    By Nitin Mahadar in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-24-2005, 10:05 AM
  5. [SOLVED] Type Mismatch Error when getting data from another workbook
    By Tony Zappal in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-12-2005, 07:06 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