Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a huge Excel sheet and I would like to get a small list of cell (around 200-300 cells from the same column, row) into a CSV string.

Is there an Excel command to do that?. Saving the file into a CSV is not much of a help as the file is quite huge.

share|improve this question
1  
Would it be an option to just copy the selected area and paste it into another worksheet? This would be quite simple with VBa –  Dave Oct 25 '13 at 7:48

1 Answer 1

up vote 1 down vote accepted

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

  1. Add a button (Form control)

    1. If the Developer tab is not available, display it.
      1. Click the Microsoft Office Button Button image, and then click Excel Options.
      2. 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.
  2. On the Developer tab, in the Controls group, click Insert, and then under ActiveX Controls, click Command Button Button image.

    Controls group

  3. Click the worksheet location where you want the upper-left corner of the command button to appear.

  4. 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_Clickwith the code inside the sub which I've posted on top of this.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.