+ Reply to Thread
Results 1 to 9 of 9

Macro to separate data based on contents of a column to 2 new excel files

  1. #1
    Registered User
    Join Date
    11-23-2010
    Location
    India
    MS-Off Ver
    Excel 2013
    Posts
    26

    Question Macro to separate data based on contents of a column to 2 new excel files

    Hello Experts,

    I need one help from you guys, I tried recording macro for this but it doesn't work every time and hence i end up incurring a lot of time on this. Thanks a lot in advance. Appreciate your kind help


    I have attached the initial file that i work on. So, basically i need 2 files created from this file as per below:

    1. The basis of creating 2 new spreadsheets from the attached file is the column D - "Host Country/ Responsible Entity" - I need to create 2 files that should look similar as the attached but one should only have details of countries starting with "USA - " while 2nd file should have details of all non US line items.
    2. I would want both the files looking as same as the attached file with 1-6 rows same for both and rest based on the above explanation.
    3. The catch here is - Everytime the number of rows and columns fluctuates and that is what i have trouble with. So, if you can share the macro code that identifies the last row/column of the sheet and then inserts total at the most bottom that would be a great help.

    Thanks again for all your help
    Attached Files Attached Files
    Last edited by beautify5; 09-11-2015 at 03:36 AM.

  2. #2
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Macro to separate data based on contents of a column to 2 new excel files

    Here's a possibility.
    Attached Files Attached Files
    Click the * Add Reputation button in the lower left hand corner of this post to say thanks.

    Don't forget to mark this thread SOLVED by going to the "Thread Tools" drop down list above your first post and choosing solved.

  3. #3
    Registered User
    Join Date
    11-23-2010
    Location
    India
    MS-Off Ver
    Excel 2013
    Posts
    26

    Re: Macro to separate data based on contents of a column to 2 new excel files

    Quote Originally Posted by skywriter View Post
    Here's a possibility.

    Thanks. It works like a charm but can you please help to add to the code to create new files for each tab, one with US and other Non US. File can be auto saved to the location of the original file. Hope this is not a big trouble for you. Thanks a lot again.

  4. #4
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Macro to separate data based on contents of a column to 2 new excel files

    Quote Originally Posted by beautify5 View Post
    Thanks. It works like a charm but can you please help to add to the code to create new files for each tab, one with US and other Non US. File can be auto saved to the location of the original file. Hope this is not a big trouble for you. Thanks a lot again.
    I'd be happy to, but where I am it is very late. I have to go to bed now.
    Someone may step in and do that for you, but my guess is a new thread with a link to this thread might get more attention.

    Thanks for the rep. points.

  5. #5
    Registered User
    Join Date
    11-23-2010
    Location
    India
    MS-Off Ver
    Excel 2013
    Posts
    26

    Re: Macro to separate data based on contents of a column to 2 new excel files

    Quote Originally Posted by skywriter View Post
    I'd be happy to, but where I am it is very late. I have to go to bed now.
    Someone may step in and do that for you, but my guess is a new thread with a link to this thread might get more attention.

    Thanks for the rep. points.
    Not a problem at all, thanks and have a nice sleep.

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro to separate data based on contents of a column to 2 new excel files

    Does this help?

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    11-23-2010
    Location
    India
    MS-Off Ver
    Excel 2013
    Posts
    26

    Re: Macro to separate data based on contents of a column to 2 new excel files

    Thanks but I am getting an Out of Memory error after running this. I dont know why so.

  8. #8
    Registered User
    Join Date
    11-23-2010
    Location
    India
    MS-Off Ver
    Excel 2013
    Posts
    26

    Re: Macro to separate data based on contents of a column to 2 new excel files

    Can you please help me with this. I am not sure why this error is popping up. I also tried on another system and same error pops up after running the macro which says "Out of memory".

  9. #9
    Registered User
    Join Date
    11-23-2010
    Location
    India
    MS-Off Ver
    Excel 2013
    Posts
    26

    Re: Macro to separate data based on contents of a column to 2 new excel files

    Quote Originally Posted by skywriter View Post
    I'd be happy to, but where I am it is very late. I have to go to bed now.
    Someone may step in and do that for you, but my guess is a new thread with a link to this thread might get more attention.

    Thanks for the rep. points.
    Hello Dear,

    Can you please help on this? I haven't got a perfect solution so far. Have been struggling to get this resolved.

+ 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: 3
    Last Post: 06-23-2015, 03:58 PM
  2. Can anyone here tweek this macro for renaming Excel files based on a cell's contents?
    By chrisd2000 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-01-2014, 02:43 PM
  3. Can a macro rename Excel files based on a cell's contents?
    By chrisd2000 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-27-2014, 09:51 AM
  4. Macro for Spiliting a file based on criteria into separate excell files
    By anto_01 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-15-2012, 07:19 PM
  5. Excel Macro to save several text files, based on the contents of two cells.
    By chronologie2 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-29-2012, 11:31 AM
  6. Replies: 8
    Last Post: 10-18-2012, 05:42 PM
  7. Replies: 3
    Last Post: 04-11-2012, 11:00 AM

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