+ Reply to Thread
Results 1 to 5 of 5

Split data to sheets and save as a csv

  1. #1
    Registered User
    Join Date
    02-02-2023
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    5

    Split data to sheets and save as a csv

    Hi all,

    I'd like a macro which will:

    1. create new sheets based on the text in Column A of the active sheet (source sheet) of where the macro is run
    2. save just the new sheets which have been created as csv files in a new folder, with the folder name as date of when the macro is run.

    I've attached an example workbook which hopefully highlights what I'm trying to achieve in step 1.

    Here's some other specifics of what the macro should do, please:

    - Shouldn't require a specific source sheet name, instead should work on whichever sheet is active i.e. whichever sheet I'm on when I run the macro
    - Should not copy hidden columns from source sheet
    - If there are duplicate values in Column A in the source sheet, then should be added to 1 single sheet (please see the attached workbook as an example)
    - Create a folder with today's date in format 'dd.mm.yyyy' e.g. 21.05.2023. The location of the folder should be 'C:\Users\kevin\Work'. This is where the new csv's should be saved.
    - It should also copy the visible headers from Row 1 on whichever source sheet the macro is being run.

    Please note:
    The data on source sheet will go to Column Z at the most (including the hidden columns), but will vary on each source sheet i.e. some sheets the data may go to Column Q, another one may go to Column S and another possibly all the way to Column Z. There data will go down to a maximum of 250 rows on any given source sheet.

    The data in the attached workbook is example data and the actual structure of the text in each cell will be completely different (not that this should hopefully make a difference to create this macro).

    Many thanks,
    Kevin
    P.s. I'm a novice at using macros - just know how to insert and run one!

    Split Data To Sheets Example.xlsx

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Split data to sheets and save as a csv

    try
    Please Login or Register  to view this content.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    02-02-2023
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    5

    Re: Split data to sheets and save as a csv

    Quote Originally Posted by jindon View Post
    try
    Please Login or Register  to view this content.
    This worked a treat, thank you!!

  4. #4
    Registered User
    Join Date
    02-02-2023
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    5

    Re: Split data to sheets and save as a csv

    Quote Originally Posted by jindon View Post
    try
    Please Login or Register  to view this content.

    I've just come across an unexpected issue with the code:

    If there are any commas in the source sheet, when exporting it as a csv it removes the comma and pushes the text after each comma into the next column.

    Could you please adjust the code so that it keeps the commas and prevents the text from splitting to the next column?

    Many thanks!

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Split data to sheets and save as a csv

    1)
    Please don't quote whole posts -- it's just clutter. If you are responding to a post out of sequence, limit quoted content to a few relevant lines that makes clear to whom and what you are responding

    2) try change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

+ 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. Need a vba to split data by criteria F:F col and save to target file wb sheets
    By henrybrothers in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-03-2022, 03:11 AM
  2. [SOLVED] Need vba to split data into multiple worksheets based on column of P & save wb with FY 16
    By johnmacpro in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-02-2016, 05:47 AM
  3. Need Macro code to split data split in 7 sheets based on variable rows in column A
    By Alija_21 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-31-2015, 08:03 AM
  4. Split raw data into several worksheet and save as new workbook filter by column name
    By dare2join in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-29-2012, 11:15 AM
  5. [SOLVED] Loop for search a string, split data, save as new file.
    By johnch in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-29-2012, 01:57 AM
  6. VBA code to split sheets and save as seperate CSV files
    By mccrimmon in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-01-2008, 01:59 PM
  7. Split data into new sheets
    By bernard in forum Excel General
    Replies: 4
    Last Post: 01-04-2006, 12:50 PM

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