+ Reply to Thread
Results 1 to 15 of 15

Macro to pull in data from excel file

  1. #1
    Forum Contributor
    Join Date
    07-21-2013
    Location
    washington dc
    MS-Off Ver
    365 MSO
    Posts
    473

    Macro to pull in data from excel file

    Hi-

    I would like to create a macro where I would be able to pull in excel data from an excel file that is in one of my drives. I am not sure where to begin. I have attached an example. Not sure if I need this in macro, but the path is listed below

    T Drive-Reports-finalized details Archive-finalizeddetails071913 (every day a new report comes in with the date). I would like to be able to pull this file daily in my macro for most recent date.
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Macro to pull in data from excel file

    Is this any help? You will need to edit the code to choose what to do with the array. Note I haven't added any proper error checks if the drive/folder/file is not found.
    Attached Files Attached Files
    *******************************************************

    HELP WANTED! (Links to Forum threads)
    Trying to create reusable code for Custom Events at Workbook (not Application) level

    *******************************************************

  3. #3
    Forum Contributor
    Join Date
    07-21-2013
    Location
    washington dc
    MS-Off Ver
    365 MSO
    Posts
    473

    Re: Macro to pull in data from excel file

    This is the code i have so far below. In workbooks.open, I have inputted the path to the spreadsheet I want. How do I make it so that it will always pull the most recent date that is dropped?
    Also, in my other worksheet I will create a macro button, and I want the data from the finalizeddetails file to pull into this worksheet begining in column I row 7.

    import
    Please Login or Register  to view this content.
    Thank you
    Last edited by JBeaucaire; 07-22-2013 at 05:18 PM. Reason: Added CODE tags, as per Forum Rules. Take a moment to read the Forum Rules in the menu bar above. Thanks.

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro to pull in data from excel file

    This will attempt to open the dated file with the latest date in the past 7 days. The macro should be IN the workbook that is the destination. The macro will paste into column I starting at the empty rows it finds from jumping UP column I from the bottom of the sheet, so make sure there is nothing else in column I. If you want the paste to start at row 7, then I6 should be the last used cell in that column.

    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 07-22-2013 at 06:15 PM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  5. #5
    Forum Contributor
    Join Date
    07-21-2013
    Location
    washington dc
    MS-Off Ver
    365 MSO
    Posts
    473

    Re: Macro to pull in data from excel file

    Hi...I am confused. Is what you wrote on the right hand side just notes explaining what you did? I don't need to amend/change anything your code? I am running excel 2010, not sure if that makes a difference. Doesn't seem to work.

    Thanks

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro to pull in data from excel file

    Anything after a ' is a comment, explanation of what the code is trying to do.


    I found some tiny errors in the xlUp references, so copy the code from above again. I don't expect there to be any code changes needed, try it again.

  7. #7
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Macro to pull in data from excel file

    Quote Originally Posted by cartica View Post
    This is the code i have so far below. In workbooks.open, I have inputted the path to the spreadsheet I want. How do I make it so that it will always pull the most recent date that is dropped?
    Also, in my other worksheet I will create a macro button, and I want the data from the finalizeddetails file to pull into this worksheet begining in column I row 7.
    Here is a revised version. Note that it only works if the import file has todays date.
    Attached Files Attached Files

  8. #8
    Forum Contributor
    Join Date
    07-21-2013
    Location
    washington dc
    MS-Off Ver
    365 MSO
    Posts
    473

    Re: Macro to pull in data from excel file

    mc84excel-

    When I run the macro you attached, I receive an error. It says could not create array from finalizeddetails072413.xls Sheet1

  9. #9
    Forum Contributor
    Join Date
    07-21-2013
    Location
    washington dc
    MS-Off Ver
    365 MSO
    Posts
    473

    Re: Macro to pull in data from excel file

    JBeaucaire-

    your macro worked in my s/s. Thank you. My only question is what would I ammend in below so that in the worksheet when I run macro the data starts to past in Column I row 7. right now it's pulling in row6.

    Please Login or Register  to view this content.
    Last edited by cartica; 07-24-2013 at 06:29 PM.

  10. #10
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro to pull in data from excel file

    When you joined the forum recently you agreed to abide by the Forum Rules, but in haste I fear you might not have actually read them. Please stop and take a moment to read them now. We all follow these rules for the benefit of all, as must you. Thanks.

    (link above in the menu bar)

    Your post #9 does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here


    I already corrected your post #1 as a courtesy demonstration, now it's your turn.

  11. #11
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Macro to pull in data from excel file

    Quote Originally Posted by cartica View Post
    mc84excel-

    When I run the macro you attached, I receive an error. It says could not create array from finalizeddetails072413.xls Sheet1
    Sorry to hear that. Unfortunately I can't tell where it's breaking without a copy of the WB you are trying to import. To maintain the confidentiality of your information, I suggest you step through the code to see which line the code is breaking on and what the messages say when you mouse hover over the variables on that line. If you can let me know that, I may be able to solve it. (It would be much much easier for me if you could upload the import WB - even if you have to replace any confidential data with dummy figures/strings).

  12. #12
    Forum Contributor
    Join Date
    07-21-2013
    Location
    washington dc
    MS-Off Ver
    365 MSO
    Posts
    473

    Re: Macro to pull in data from excel file

    can you tell me more about below means.

    Please Login or Register  to view this content.

  13. #13
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro to pull in data from excel file

    It means find the range that encompasses A2 down to the last used cell in column P, copy that range, then paste it into the new sheet starting at the next empty cell in column I.

  14. #14
    Forum Contributor
    Join Date
    07-21-2013
    Location
    washington dc
    MS-Off Ver
    365 MSO
    Posts
    473

    Re: Macro to pull in data from excel file

    In the below Macro, after I clearout my previous data, what code do I need, and where to be able to then populate cell L64:L69 with data from B23:B28? Thanks

    Please Login or Register  to view this content.

  15. #15
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro to pull in data from excel file

    If those are 5 unmerged cells, maybe:

    Please Login or Register  to view this content.

    If those cells are actually one big merged cell, even simpler:

    Please Login or Register  to view this content.

+ 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. Using a macro to pull specific data from multiple files into a master file
    By bocaj315 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-04-2013, 09:31 AM
  2. Vlookup query : How to pull data from raw excel files into a master excel file?
    By jamesjamesiata in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-22-2013, 06:26 AM
  3. Need to pull data from zillow into excel file.
    By jtaylor13 in forum Excel General
    Replies: 11
    Last Post: 11-06-2012, 08:34 PM
  4. Macro to pull data from another file.
    By eface2face in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 11-23-2010, 03:25 PM
  5. outlook macro to pull in a table from excel file to email.
    By chewwy in forum Outlook Programming / VBA / Macros
    Replies: 0
    Last Post: 08-18-2009, 03:10 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