+ Reply to Thread
Results 1 to 7 of 7

Macro to copy selected columns and convert the file into multiple csvmsdos files

  1. #1
    Registered User
    Join Date
    06-01-2012
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    9

    Question Macro to copy selected columns and convert the file into multiple csvmsdos files

    Hi Team,

    Would like to know the Macro to copy selected columns with conditions and convert the file into multiple .csvmsdos files. I have the code to convert the excel file to multiple .csvmsdos files with specific name; However I am unable to code the macro to copy specific columns with conditions to those csv files. Attached is the file with sample data. following is the action I would like to execute :

    Search for cells that has Day 1 in column 'C' and RNA in column 'D'
    Copy and paste all those data as values into a new file and save the file in .csvmsdos format with name RNA_Day 1_todays date <I have the code to copy all the data and save the file in .csvmsdos format with name RNP_Day 1_todays date which is available in the attached file>

    Next Search for cells that has Day 1 in column 'C' and RND in column 'D'
    Copy and paste all those data as values into a new file and save the file in .csvmsdos format with name RND_Day 1_todays date

    Next Search for cells that has Day 1 in column 'C' and RNP in column 'D'
    Copy and paste all those data as values into a new file and save the file in .csvmsdos format with name RNP_Day 1_todays date

    Next Search for cells that has Day 1 in column 'C' and DNP in column 'D'
    Copy and paste all those data as values into a new file and save the file in .csvmsdos format with name DNP_Day 1_todays date

    So on so forth for Day 1,3,5,7,10,15,20,25,30,40,50 and 60 for RNA/RNP/RND/DNP and files to be saved at specific location.

    Kindly help. I have the code to save the file with complete data to .csvmsdos format at a specific location with a specified filename.

    Regards,
    Tanay
    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: Macro to copy selected columns and convert the file into multiple csvmsdos files

    This will do it:

    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 05-08-2014 at 02:49 AM. Reason: Correction
    _________________
    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
    Registered User
    Join Date
    06-01-2012
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Macro to copy selected columns and convert the file into multiple csvmsdos files

    Thanks JBeaucaire,

    However what would I need to change in the syntax if I want only Column A and B in all CSV sheets.

  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 copy selected columns and convert the file into multiple csvmsdos files

    I've highlighted that above.

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

  5. #5
    Registered User
    Join Date
    06-01-2012
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Macro to copy selected columns and convert the file into multiple csvmsdos files

    Even after the change it copies all columns A to D in all the csv files. Kindly let me know what is the change needed in the code above as the change you have highlighted doesn't solve the query.

  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 copy selected columns and convert the file into multiple csvmsdos files

    Forgot to take out the .CurrentRegion in that same line of code. Grab the code again from above.

  7. #7
    Registered User
    Join Date
    06-01-2012
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Macro to copy selected columns and convert the file into multiple csvmsdos files

    Thanks a Lot

+ 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. Copy columns from multiple files into single file
    By kevincoxshall in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-10-2014, 02:39 PM
  2. [SOLVED] Need a macro to copy paste data from multiple files into a file as a database
    By etandogan in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 12-13-2012, 02:14 AM
  3. Copy-Paste Macro of 3 columns from multiple excel files into one summary file
    By jpmaster53 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-15-2012, 07:10 AM
  4. Apply macro to multiple CSV files and then convert to XLS or TXT file,
    By asok in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-24-2012, 10:13 AM
  5. Macro to copy selected columns, convert to number and paste to new tab
    By Greed in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-06-2011, 06:11 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