You can use a VBA-macro. Change the range, to whatever you want. I choose A1:B3. Also you should change the filepath to a path, which you like.
Sub CopyToCSV()
Sheets(1).Range("A1:B3").Copy
Workbooks.Add
ActiveSheet.Paste
ActiveWorkbook.SaveAs Filename:= _
"C:\Temp\yourCSV.csv" _
, FileFormat:=xlCSV, CreateBackup:=False, Local:=True
Application.DisplayAlerts = False
ActiveWorkbook.Close
Application.DisplayAlerts = True
End Sub
How to add a button to the excel-sheet to execute the macro
Add a button (Form control)
- If the Developer tab is not available, display it.
- Click the Microsoft Office Button Button image, and then click Excel Options.
- In the Popular category, under Top options for working with Excel, select the Show Developer tab in the Ribbon check box, and then
click OK.
On the Developer tab, in the Controls group, click Insert, and then under ActiveX Controls, click Command Button Button image.
![Controls group](../../I/static/images/32fdf51f11ab3804b33d7c6267634810f03a9f0ec9555b86add44c856deca928.gif)
Click the worksheet location where you want the upper-left corner of the command button to appear.
- In the Controls group, click View Code.
This starts the Visual Basic Editor. Make sure that Click is selected in the dropdown
list on the right. The sub procedure called CommandButton1_Click
, as
shown in the following picture, runs two macros when the button is
clicked.
Source
Now just repace the code of the CommandButton1_Click
with the code inside the sub which I've posted on top of this.
1Would it be an option to just copy the selected area and paste it into another worksheet? This would be quite simple with VBa – Dave – 2013-10-25T07:48:01.847