+ Reply to Thread
Results 1 to 4 of 4

Save worksheets as csv files in a given directory

  1. #1
    Forum Contributor
    Join Date
    02-20-2009
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    467

    Save worksheets as csv files in a given directory

    I have three worksheets (called 'Events', 'Markets', 'Selections') that I want to save columns A:L as a csv file in a specified directory.

    I want to do this through some vba code to put in a button on a worksheet.

    The file name of the csv file wants to be " 'User defined description'_&'Worksheet Name' &'current date/time'...

    i.e. UserDescription_Events_28-06-2011_15:26:33.csv

    The beginning of the code wants a message box to appear for the user to enter the 'User Description'.

    Thank you in advance.

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Save worksheets as csv files in a given directory

    Maybe something like this:

    Please Login or Register  to view this content.

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Forum Contributor
    Join Date
    02-20-2009
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    467

    Re: Save worksheets as csv files in a given directory

    Thanks for this Dom. I have amended it a little to suit my needs but it works great.

    I would also like to add to this code now by also saving the workbook to a different directory with the same filename and this time as .xls file.

    Please Login or Register  to view this content.
    I tried to add the bit beneath ''SAVE WORKBOOK IN SPECIFIED FOLDER" but was getting errors when I tried to run the code. Can someone tell me what schoolboy error I am making?

    Thanks,
    Adam.

  4. #4
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Save worksheets as csv files in a given directory

    Try using FileFormat:=xlNormal

    If it's already an Excel file you don't need to specify the format though.

    Dom

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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