Você pode usar uma macro VBA. Altere o intervalo para o que você quiser. Eu escolho A1: B3. Além disso, você deve alterar o caminho do arquivo para um caminho que você gosta.
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
Como adicionar um botão ao excel-sheet para executar a 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.
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 calledCommandButton1_Click
, as shown in the following picture, runs two macros when the button is clicked.
Agora apenas repita o código do CommandButton1_Click
com o código dentro do sub que eu postei sobre isso.