Saving to CSV

DougDR

Board Regular
Joined
Jun 6, 2011
Messages
121
<!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:PunctuationKerning/> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:Compatibility> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" LatentStyleCount="156"> </w:LatentStyles> </xml><![endif]--><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0mm 5.4pt 0mm 5.4pt; mso-para-margin:0mm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]--> Inside a workbook I have a worksheet that is a reconciliation of information from other worksheets in the same workbook. This worksheet needs to be saved as a “ ##.csv “ file. My problem is that the save as saves the hole workbook as a csv file so I have to close the workbook down and reopen it so that I the original file to continue working with.

IS there a way to save one worksheet in a workbook as a “ ##.csv “ file without changing the name condition of the workbook file? Maybe some form of export?

Also: here on the message board, how can I bring attention to a previous posting.
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Maybe something like this...

Code:
[font=Verdana][color=darkblue]Option[/color] [color=darkblue]Explicit[/color]

[color=darkblue]Sub[/color] SaveAsCSV()

    [color=green]'Declare variable[/color]
    [color=darkblue]Dim[/color] strPath [color=darkblue]As[/color] [color=darkblue]String[/color]

    [color=green]'Assign path to original workbook[/color]
    strPath = ThisWorkbook.Name

    [color=green]'Create a new workbook containing Sheet1 (change accordingly)[/color]
    ThisWorkbook.Sheets("Sheet1").Copy
    
    [color=green]'Save new workbook as CSV file[/color]
    ActiveWorkbook.SaveAs Filename:=strPath & ActiveWorkbook.Name & ".csv", FileFormat:=xlCSV
    
    [color=green]'Close new workbook[/color]
    ActiveWorkbook.Close savechanges:=[color=darkblue]False[/color]
    
[color=darkblue]End[/color] [color=darkblue]Sub[/color]
[/font]
 
Upvote 0
This looks great thank you very much I will try it and let you know how it works out. Thanks again for the help .............!:)

Maybe something like this...

Code:
[FONT=Verdana][COLOR=darkblue]Option[/COLOR] [COLOR=darkblue]Explicit[/COLOR]

[COLOR=darkblue]Sub[/COLOR] SaveAsCSV()

    [COLOR=green]'Declare variable[/COLOR]
    [COLOR=darkblue]Dim[/COLOR] strPath [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]String[/COLOR]

    [COLOR=green]'Assign path to original workbook[/COLOR]
    strPath = ThisWorkbook.Name

    [COLOR=green]'Create a new workbook containing Sheet1 (change accordingly)[/COLOR]
    ThisWorkbook.Sheets("Sheet1").Copy
    
    [COLOR=green]'Save new workbook as CSV file[/COLOR]
    ActiveWorkbook.SaveAs Filename:=strPath & ActiveWorkbook.Name & ".csv", FileFormat:=xlCSV
    
    [COLOR=green]'Close new workbook[/COLOR]
    ActiveWorkbook.Close savechanges:=[COLOR=darkblue]False[/COLOR]
    
[COLOR=darkblue]End[/COLOR] [COLOR=darkblue]Sub[/COLOR]
[/FONT]
 
Upvote 0
Also: here on the message board, how can I bring attention to a previous posting.

Just reply to your original posting saying you need more help and it will take it to the top.
 
Upvote 0
Thanks again ... Don't hold your breath, but I hope I can help yousome time ....
 
Upvote 0

Forum statistics

Threads
1,223,229
Messages
6,170,881
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top