Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Save one worksheet from a workbook to a new .csv file

Hi,

In code, how can I save one specific worksheet from a workbook with many
worksheets to a new .csv file. I've looked at the SaveAs Method in Help but I
don't see the answer there. Any help would be appreciated.
--
Thanks.
Chuck M.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Save one worksheet from a workbook to a new .csv file

Hi Chuck

Try this for the activesheet

Sub ActiveSheet_CSV_File()
Dim wb As Workbook
Dim strdate As String
Dim Fname As String
strdate = Format(Now, "dd-mmm-yy h-mm-ss")
Fname = "C:\Part of " & ThisWorkbook.Name _
& " " & strdate & ".csv"
Application.ScreenUpdating = False
ActiveSheet.Copy
Set wb = ActiveWorkbook
With wb
.SaveAs Fname, FileFormat:=xlCSV
.Close False
End With
Application.ScreenUpdating = True
End Sub




--
Regards Ron de Bruin
http://www.rondebruin.nl



"Chuck M" wrote in message ...
Hi,

In code, how can I save one specific worksheet from a workbook with many
worksheets to a new .csv file. I've looked at the SaveAs Method in Help but I
don't see the answer there. Any help would be appreciated.
--
Thanks.
Chuck M.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Save one worksheet from a workbook to a new .csv file

Hi Ron,

That works perfectly.

Thanks for the quick response.
--
Thanks.
Chuck M.


"Ron de Bruin" wrote:

Hi Chuck

Try this for the activesheet

Sub ActiveSheet_CSV_File()
Dim wb As Workbook
Dim strdate As String
Dim Fname As String
strdate = Format(Now, "dd-mmm-yy h-mm-ss")
Fname = "C:\Part of " & ThisWorkbook.Name _
& " " & strdate & ".csv"
Application.ScreenUpdating = False
ActiveSheet.Copy
Set wb = ActiveWorkbook
With wb
.SaveAs Fname, FileFormat:=xlCSV
.Close False
End With
Application.ScreenUpdating = True
End Sub




--
Regards Ron de Bruin
http://www.rondebruin.nl



"Chuck M" wrote in message ...
Hi,

In code, how can I save one specific worksheet from a workbook with many
worksheets to a new .csv file. I've looked at the SaveAs Method in Help but I
don't see the answer there. Any help would be appreciated.
--
Thanks.
Chuck M.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I save a worksheet within a workbook? jester Excel Discussion (Misc queries) 1 August 7th 06 10:54 PM
Save worksheet vs workbook JWM6[_18_] Excel Programming 3 May 3rd 06 04:45 PM
Save Every Worksheet as its own Workbook Michael Smith Excel Programming 11 February 25th 05 04:22 PM
Save Workbook or worksheet Hugh Excel Programming 3 October 22nd 04 02:01 PM
save worksheet as new workbook dreamer[_12_] Excel Programming 6 February 19th 04 02:56 PM


All times are GMT +1. The time now is 07:42 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"