+ Reply to Thread
Results 1 to 16 of 16

Import data from Closed Workbooks

  1. #1
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Import data from Closed Workbooks

    Hello

    H had a similar thread but the position here is different

    I have four workbooks in the same folder
    One named (ODI) this is where I want to import data as values ..
    All what I want to do to import data from other adjacent workbooks (Record01 - Record02- Record03) from sheet named with the same name in these workbooks named (Data).

    The range to be copied from (Data) sheet from A1:L & LastRow

    Another impotant point :::
    I want to exclude some rows depending on a condition .. My condition is Column L has "From" text .. If the cells say L14="From" this row is to be excluded from copying.
    Or this can be done by deleting rows which contains this text after copying data
    Here's an attachment
    Attached Files Attached Files

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

    Re: Import data from Closed Workbooks

    This should do it. Install it into a regular code module in your ODI workbook. Make sure all your workbooks are in the same folder with this workbook, then give it a run.

    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 11-03-2014 at 09:56 AM.
    _________________
    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!)

  3. #3
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Import data from Closed Workbooks

    Mr. JBeaucaire
    Perfect Solution and awesome code
    Just one last point >> paste data as values

  4. #4
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Import data from Closed Workbooks

    Quote Originally Posted by YasserKhalil View Post
    Mr. JBeaucaire
    Perfect Solution and awesome code
    Just one last point >> paste data as values
    Please the last point in this code

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

    Re: Import data from Closed Workbooks

    This one line of code:
    Please Login or Register  to view this content.

    ...becomes two lines:
    Please Login or Register  to view this content.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  6. #6
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Import data from Closed Workbooks

    Thanks for your reply Mr. JBeaucaire
    The problem of the code is that it destroys the formats prepared in the WB "ODI"
    I think this is because of deleting the rows ..

    Another point There are three messages during executing the code
    (There is a large mount of information on the clipboard ....)

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

    Re: Import data from Closed Workbooks

    The pastespecial Values code will not destroy any column formatting. You may need to reapply that formatting for now, but after that the new code line will not change any cell formats as it is pasting data values only.


    You can try this to see if it suppresses that message:
    Please Login or Register  to view this content.

  8. #8
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Import data from Closed Workbooks

    I already do the change .. Thanks for getting rid of these messages
    But still destroys the formats of the worksheet

    Can you modify the code so as not to delete the rows which contains the word "From"?
    I think it will be easy for me to use another code to do that without using filte and deleting rows

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

    Re: Import data from Closed Workbooks

    There I a line at the top of the macro that is resetting the sheet, my bad:
    Please Login or Register  to view this content.

    Change that to:
    Please Login or Register  to view this content.


    The code in RED above in post #2 is the filter that removes the FROM rows. It is the exact same AutoFilter approach you would be doing manually, so I don't think you need to removed it, but you can. All the red lines.

  10. #10
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Import data from Closed Workbooks

    Thanks for these valuable information
    Now it is almost to be done
    Just want to start data at A1 without deleting Row A as I have dynamic ranges which is related to row A
    This will be the last request Mr. JBeaucaire
    Thank you very much for your patience

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

    Re: Import data from Closed Workbooks

    The code I suggested was based off of the workbook you provided, we are changing a LOT after the fact, so be sure to start with your actual finished / designed workbook next time and include all the specifications so we don't write a bunch of stuff and then have to rewrite the whole thing, ok?

    So, to remove the FROM rows with an autofilter requires row1 to have titles, your ODI sheet does not. The data being copied in is starting at row2, then row 1 is used for the autofilter, so all that is working. We can leave the data on row2 and just clear row1, or leave row1 as titles, but we can't put the data on row2 so it can be filtered and then cut/paste it up into row1 without trashing your named ranges the same way deleting row1 does, that's my guess.

    So what do you suggest?

    You could change that last line that deletes row1 to just a ClearContents command and leave the empty blank row?

  12. #12
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Import data from Closed Workbooks

    Mr. JBeaucaire
    I'm sorry for making you change alot .. I don't expect the code will destroy my dynamic ranges > The results are not expected for me.
    You provide me with your wonderful codes and I try them and see the results ... If anything or any error appears I inform you !!
    Generally I'm satisfied of the results until now .. I can change my dynamic ranges so as to start A2 instead of A1

  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: Import data from Closed Workbooks

    Quote Originally Posted by JBeaucaire View Post
    You could change that last line that deletes row1 to just a ClearContents command and leave the empty blank row?

    Did you try this?

  14. #14
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Import data from Closed Workbooks

    Yes I tried it and everthing is OK except this empty blank row!!
    But we can stop at this point . I'm satisfied with the results

  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: Import data from Closed Workbooks

    Great. If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  16. #16
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Import data from Closed Workbooks

    I marked the thread as solved ..
    But if you can help me getting rid of the first empty row without destroying dynamic ranges I will be very grateful for you.. even if after some time ..

+ 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: 0
    Last Post: 03-27-2014, 12:38 PM
  2. Import data from several closed workbooks to a single sheet in an open workbook
    By drewship in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-04-2013, 06:35 AM
  3. code to import data from a closed workbook
    By jeepguy8794 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-27-2011, 05:44 PM
  4. Import data from different closed workbooks
    By shah0101 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-01-2008, 07:17 AM
  5. [SOLVED] How do I import data from a closed Excel Spreadsheet?
    By Tomcat in forum Excel General
    Replies: 2
    Last Post: 05-30-2006, 07:55 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