+ Reply to Thread
Results 1 to 8 of 8

Copy specific row data with condition and paste into new workbook

  1. #1
    Registered User
    Join Date
    12-13-2012
    Location
    India, New Delhi
    MS-Off Ver
    Excel 2010
    Posts
    16

    Copy specific row data with condition and paste into new workbook

    Hi,

    I have a database as below

    Column A titled as 'Group' Column B titled as 'Name'
    A2 - ACE B2 - sadflknsdj
    A3 - ACE B3 - kfnjbasdjca
    A4 - ACE B4 - inisdbaubc
    A5 - ACCA B5 - mnnfdni
    A6 - ACCA B6 - iknunc
    A7 - ACE B7 - fikniens
    A8 - LOAD B8 - jnwebcbd
    A9 - ACCA B9 - iweybdeca
    A10 - LOAD B10 - jjvbbfs

    I want to copy column A & B data of each Group and paste it into new workbook which to be renamed by its Group and all these workbooks to be saved into a single folder.

    For Ex: 1st Group is ACE

    in 1st Workbook name (ACE), the data should come out as below:

    Column A titled as 'Group' Column B titled as 'Name'
    A2 - ACE B2 - sadflknsdj
    A3 - ACE B3 - kfnjbasdjca
    A4 - ACE B4 - inisdbaubc
    A5 - ACE B5 - fikniens

    Smilarly, in 2nd Workbook name (ACCA), the data should come out as below:

    Column A titled as 'Group' Column B titled as 'Name'
    A2 - ACCA B2 - mnnfdni
    A3 - ACCA B3 - iknunc
    A4 - ACCA B4 - iweybdeca

    Similarly for 3rd workbook and so on....!!! until the Column A data doesn't go blank.

    **you can assume any path of a folder to save these workbooks.

    Thanks in advance!!
    Last edited by tdugga; 10-21-2013 at 12:29 PM. Reason: typo

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

    Re: Copy specific row data with condition and paste into new workbook

    Maybe:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    12-13-2012
    Location
    India, New Delhi
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Copy specific row data with condition and paste into new workbook

    Thanks for revert, John. I appreciate your efforts!!

    Separate Workbooks are getting created on the name of the Group but it's data is not getting captured. These workbooks are actually blank.

    Also, I want to set the path of a folder into which these workbooks should get saved one by one with desired data.

    Moreover, these workbooks remain Open. these should get closed once data is been captured.

    Thanks!!

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

    Re: Copy specific row data with condition and paste into new workbook

    When I tested it on a sample I created it copied the data too the newly created workbooks. Can you provide a sample, so I can see where the problem may be. Also provide a path folder for where you want the files stored, so I can make changes in the code. To attach a file, push the button with the paperclip (or scroll down to the Manage Attachments button), browse to the required file, and then push the Upload button.

  5. #5
    Registered User
    Join Date
    12-13-2012
    Location
    India, New Delhi
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Copy specific row data with condition and paste into new workbook

    Here is the sample sheet with your script embedded. Please take a look and confirm.

    I am using MS Excel 2010 version, hope this is not the problem area.

    Folder path - anywhere in D Drive (D:\tdugga\......)
    Attached Files Attached Files

  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: Copy specific row data with condition and paste into new workbook

    Maybe that was the problem. I at first had the files saving as .xls now I changed to .xlsx.

    Please Login or Register  to view this content.
    You need to make two changes in the code. I think you'll understand. They are highlighted in red. Again the code worked for me on the sample you provided.

  7. #7
    Registered User
    Join Date
    12-13-2012
    Location
    India, New Delhi
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Copy specific row data with condition and paste into new workbook

    Hi,

    I am sorry but this time also it doesn't give end result in desired format.

    1. This script is giving error at the time of closing new workbooks.
    2. New Workbooks are getting created with its correct Group name but data is not getting pasted in it. Whole workbook is blank.
    3. In Sample FAR.xlsm workbook, A blank row is getting inserted in between of non matching groups. (Below data is for reference)

    Group Name
    ACE sadflknsdj
    ACE kfnjbasdjca
    ACE inisdbaubc

    ACCA mnnfdni
    ACCA iknunc

    ACE fikniens

    LOAD jnwebcbd

    ACCA iweybdeca

    LOAD jjvbbfs

    Please apply some different trick to function this.

    Thanks for valuable time & efforts.!! Much appreciated.

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

    Re: Copy specific row data with condition and paste into new workbook

    Did you make the changes highlighted in Red? On of them is the name of your original workbook. The code I provided still works on the sample you provided when I test it. I don't know what else to offer?

+ 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. To copy specific rows after passing a condition into another workbook.
    By aysrun in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-10-2013, 03:15 AM
  2. Replies: 0
    Last Post: 05-08-2013, 02:47 PM
  3. [SOLVED] Code to copy and paste a row into another sheet of the workbook when a condition is met.
    By oldboots in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-09-2013, 03:03 AM
  4. copy rows to specific worksheets in another workbook based on a condition
    By AngelaM in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-22-2012, 12:36 PM
  5. Copy and Paste Special Values Macro ignoring cells with specific condition
    By chendriks47 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-06-2011, 03:01 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