+ Reply to Thread
Results 1 to 25 of 25

Extracting data from one excel file to another

  1. #1
    Registered User
    Join Date
    06-06-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    14

    Extracting data from one excel file to another

    Hello
    I have an excel file (800,000+ rows) in the form (for example)-

    a 9
    a 7
    a 9
    b 10
    b 32
    b 2
    c 5
    c 3
    c 7

    I want to know if there is a way to quickly select all the rows that contain 'a' and export them to another excel file. Similarly, all the rows with 'b' would be exported to another excel file.

    Is there a query that can solve this?
    Please let me know how to do this.
    Thank you

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,054

    Re: Extracting data from one excel file to another

    Create Pivot table and then from Report Filter click Show Report Filter Pages.

    That will place you each letter (a,b,c) in it's own sheet.

    Is this good enough?

    To create workbook from each critertia you would need VBA
    Never use Merged Cells in Excel

  3. #3
    Registered User
    Join Date
    06-06-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Extracting data from one excel file to another

    Hello, thank you for your reply, I have attached a small extract of the huge excel file that I have to work with.
    As you can see, I would like all the rows that have 'Fuso-class battleship' to be in a new excel file. Similarly, 'Gifu, Gifu' and all its rows should be in another excel file.
    Will pivot table work in this case?
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    06-06-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Extracting data from one excel file to another

    bump bump bump

  5. #5
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,054

    Re: Extracting data from one excel file to another

    It's not that easy to bump so soon

    Here, try this:

    1. First define somewhere to save your files. Example is C:\Users\zbor\Documents\Excel forum\
    2. Define first row for headers (names doesn't matter)
    Attached Files Attached Files
    Last edited by zbor; 06-06-2013 at 03:35 PM.

  6. #6
    Registered User
    Join Date
    06-06-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Extracting data from one excel file to another

    Thank you so much for the reply once again, and I apologize for bumping too soon.

    After changing the file output directory in the macro to the desktop and after pressing 'save each file' I get folders named as '3Gifu, gifu', '3Brandon Graham'
    which is fine. But when I try to open them, I get a message -

    'The file you are trying to open, '3Gifu, Gifu.xls' is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?'

    When I click open, I get an empty workbook. Please let me know if I'm doing something wrong.

    I have also attached what my desired output should look like for two of the titles.

    I really appreciate you taking time to help me with this problem.
    Attached Files Attached Files

  7. #7
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,054

    Re: Extracting data from one excel file to another

    I've edited mine post some 10 minutes after first one. did you get mine 2nd one?

  8. #8
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,054

    Re: Extracting data from one excel file to another

    For the error try change format into xlsx

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    06-06-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Extracting data from one excel file to another

    Thank you so much that worked like a charm :D

    Now I was trying to do the same for the original excel file which is 5.45 mb so I cannot attach it in this thread, so could you please walk me through on how you did the previous file that you attached?
    I opened the original file and copy-pasted the code that you did. I would like to know what other steps have to be done.

  10. #10
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,054

    Re: Extracting data from one excel file to another

    That's it:
    1. Add first row for title
    2. Copy-paste code
    3. set sheet names and folder path
    4. run code

  11. #11
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,054

    Re: Extracting data from one excel file to another

    oh, yes, and I think I set to 1000 unique names. Do you have more than that?

  12. #12
    Registered User
    Join Date
    06-06-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Extracting data from one excel file to another

    I have 800 unique names so that is fine.

    I'm not too clear about the steps-
    So I first open the 5.45mb excel file, I set the first row for the titles,
    copy and paste your code and run, but it does not work, i'm sure i missed something?
    Last edited by kclalwani; 06-06-2013 at 04:52 PM.

  13. #13
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,054

    Re: Extracting data from one excel file to another

    Are your sheets named sheet1 where your data is stored and you have sheet2?
    If yes, try to select some cell in sheet1 and run code.
    Save your sheet as .xlsm

    Also, it might take a while to do all that

  14. #14
    Registered User
    Join Date
    06-06-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Extracting data from one excel file to another

    The sheets are named as 'Sheet1' and 'Sheet2'.

    After copy-pasting the code and running it, nothing happens. I selected the first few rows from sheet 1 and tried running it but still did not work.

  15. #15
    Registered User
    Join Date
    06-06-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Extracting data from one excel file to another

    Does it have anything to do with the 'save each file' button you placed in the folder you sent me?
    Last edited by zbor; 06-06-2013 at 05:10 PM.

  16. #16
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,054

    Re: Extracting data from one excel file to another

    No. But you can insert some button on Sheet1 and assign macro and try. Let me meanwhile check the code.

    Does it create list on Sheet2?

  17. #17
    Registered User
    Join Date
    06-06-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Extracting data from one excel file to another

    It does not create any list on Sheet2.

  18. #18
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,054

    Re: Extracting data from one excel file to another

    Remove On Error Resume Next from second macro.
    What error does it have now?

  19. #19
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,054

    Re: Extracting data from one excel file to another

    Or just copy your data into mine workbook

  20. #20
    Registered User
    Join Date
    06-06-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Extracting data from one excel file to another

    I get -
    Run-time error '1004':
    This command requires at least two rows of source data. you cannot use the command on a selection in only one row.

  21. #21
    Registered User
    Join Date
    06-06-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Extracting data from one excel file to another

    When I copy my my data into your workbook and run the code, I only get the output for the 4 unique names that I sent you as a sample and not all the 800.

  22. #22
    Registered User
    Join Date
    06-06-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Extracting data from one excel file to another

    Actually, I do not get any output at all when I copy- paste my data into your workbook and run your code.
    Last edited by kclalwani; 06-06-2013 at 05:40 PM.

  23. #23
    Registered User
    Join Date
    06-06-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Extracting data from one excel file to another

    If its not working out, then, is there a way I can send you the 5.45mb excel file? And then you can run the code? Maybe I must have missed a step because I still get error "Run-time error '1004' " That way It will be easier to find the fault.
    Even after zipping the excel file and uploading in this thread I still get an error that its too large. Please let me know. I really appreciate the way you've been helping me with my problem
    Last edited by kclalwani; 06-06-2013 at 05:54 PM.

  24. #24
    Registered User
    Join Date
    06-06-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Extracting data from one excel file to another

    Hello again zbor
    I just wanted to let you know that I figured it out. When I'm copying my data to your file, I have to make sure that my workbook is in xlsm format before I copy it to your workbook.
    I really appreciate you taking the time to help me. Thank you so much
    I have marked this thread as 'solved'

  25. #25
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,054

    Re: Extracting data from one excel file to another

    Glad I've helped.
    Limit for uploading files on the forum is 1MB.
    But it's solved now so no need for that.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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