Save one sheet of a work book as .csv?

option

Registered User.
Local time
Today, 07:30
Joined
Jul 3, 2008
Messages
143
Hey guys,

I have a workbook of 8 pages and on the 6th page, all of the information that the user has input is stored there. Once complete, I would like the user to be able to click a button to save a copy of just page 6 as a .csv to another folder. Is this possible? **Note** Pages 4-8 are not visible to the user, so the save button would probably wind up on page 2 of the spreadsheet. Thanks in advance guys!!:o
 
Code:
thisworkbook.worksheets("Page 6").saveas filename:="blah", fileformat:= xlcsv
 
tried using that and got an error. could it be because im not specifying the save location?
 
Well, I got it to work now, except its saving the entire workbook.

Code:
ThisWorkbook.Worksheets("Var").SaveAs "c:\saveddaily\user" & Format(Date, "mmddyy") & ".csv"

That's what I'm using to save where "Var" is the sheet I need to save.
 
you've not specified the file format tacking .csv onto the end isn't specifying the format you need to include:

fileformat:= xlcsv
 
To qualify what @chergh has said, you'll probably also need to suppress warnings as, when saving a multi-sheet Excel file to CSV, you'll get a warning that CSV doesn't support multiple sheets.

Also, the file the user will have open then will be the CSV, not the XLS, file. Be sure to save any changes that they've made and you want to keep in the XLS file before doing the Save As!
 
That's the whole thing...we don't want to save anything in the xls. Hence saving the csv. As far as not specifying the ".csv" , thats at the very end of my line of code (which works btw). I get no warnings when I save using my code. It saves the modified xls as a csv. Maybe I'm asking the question wrong, but I don't know how else to word it...
 
actually I made a mistake in the fileformat it should be

fileformat:= xlCSVMSDOS

Just putting a csv file extension is not specifying the format, there are a lot of csv formats out there

Your code needs to be:

Code:
ThisWorkbook.Worksheets("Var").SaveAs filename:="c:\saveddaily\user" & Format(Date, "mmddyy") , fileformat:=xlCSVMSDOS
 
Hmm...it's saving the whole workbook and setting focus to that sheet on open for me.
 
Once I close and reopen the file it only contains one worksheet for me.
 
Hmm...not me, and we're using the same code......I've tried on 3 different machines all with the same result.
 
Have you tried creating a new workbook and creating a sub with only that 1 line of vba in it?
 
Fixed it. Thanks a ton for being so helpful and patient!!
 
Last edited:

Users who are viewing this thread

Back
Top Bottom