+ Reply to Thread
Results 1 to 6 of 6

Export Specific Columns from a Worksheet as csv

Hybrid View

  1. #1
    Valued Forum Contributor Saarang84's Avatar
    Join Date
    02-19-2009
    Location
    Chennai, India
    MS-Off Ver
    XL 2003 to 2010
    Posts
    812

    Export Specific Columns from a Worksheet as csv

    Hi,

    I've a worksheet with columns of data. I would want to export specific columns into a csv file based on certain condition.

    I've attached a sample workbook. As shown in the example in the Output sheet, I need to export columns D and K based on day of week (1 = Sunday, 2 = Monday, ... 7 = Saturday) into a csv file, prefixed with a certain column with fixed value as "Add" or "Remove". I want the csv file to be saved on the disk at a user-defined location.

    How can this be done ? Can anyone help me code a vba Sub / function ?


    Sarang
    Attached Files Attached Files
    If my assistance has helped, there is a reputation icon * on the left hand corner below the post - you can show your appreciation to the user who has helped in resolving your requirement.

    If your requirement has been solved please mark your thread as Solved.
    In the menu bar above the very first post, select Thread Tools, then select "Mark this thread as Solved".

    Kindly use [FORMULA] or [CODE] tags when posting your code.

    Regards,
    Sarang

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Export Specific Columns from a Worksheet as csv

    Hi,

    Are there just two weeks worth of data, i.e. columns B:O or do you have many more extending across from P:?? in a similar way and you would want to pick up every 7th (day) column for your csv?
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Export Specific Columns from a Worksheet as csv

    Hi,

    See attached

    Change the variables as necessary on the Variable Tab, i.e the day number, text to add and file path\name
    Attached Files Attached Files

  4. #4
    Valued Forum Contributor Saarang84's Avatar
    Join Date
    02-19-2009
    Location
    Chennai, India
    MS-Off Ver
    XL 2003 to 2010
    Posts
    812

    Re: Export Specific Columns from a Worksheet as csv

    The worksheet range would grow to a maximum of four Day7 weekdays in a month.
    It would be nice to search for specific weekday columns, as I would need to pick all such columns named Day7.

  5. #5
    Valued Forum Contributor Saarang84's Avatar
    Join Date
    02-19-2009
    Location
    Chennai, India
    MS-Off Ver
    XL 2003 to 2010
    Posts
    812

    Re: Export Specific Columns from a Worksheet as csv

    This code doesn't work with my real data which is alphanumeric. Also, the day order (in the source sheet) from Day1 to Day7 is not arranged in order.

    And I would need an option to get the data for specific week or the two weeks together i.e. 1st & 2nd week, or 2nd & 3rd week, or 3rd & 4th week, etc.

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Export Specific Columns from a Worksheet as csv

    Hi,

    With the greatest of respect it behoves you to mention up front everything that is relevant or we all end up wasting our time.
    Did you not think it important to mention that the data is not in order. That's a vital piece of information. As is the fact that you apparently don't necessarily want all weeks but sometimes different groups of weeks.

    Not many of us are happy to spend time giving solutions to examples that don't represent the real world. If you study the code it will give you the general idea. You need to modify it to identify which days are relevant and build those columns into the range Union function.

+ 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. Export specific columns in different order without header to csv
    By w2kbug in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-24-2014, 04:42 AM
  2. [SOLVED] I need to export specific columns to a pipe delimiter file instead of entire worksheet.
    By lengwer in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-15-2013, 03:50 PM
  3. Macro to export specific range of data to text file for each worksheet
    By sonofamonkey10 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-30-2013, 05:43 PM
  4. Export Columns to New Worksheet
    By Ray789 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-26-2010, 01:09 PM
  5. Save\export specific worksheet error
    By SarahPintal in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-23-2010, 05:12 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