How to save each row in an Excel table as an individual .CSV file

EsJonesy

New Member
Joined
Aug 22, 2016
Messages
4
I am currently trying to automate the process of saving each row in an Excel file as an individual .csv file. I was able to record the below code when doing it manually for 1 row and would like to automate this for all rows.

I'm hoping someone might be able to point me in the right direction.

Some issues I have:

  • Each file needs to save as the File Name listed in Column A.
  • When copying the data, I need it to ignore cells that are blank.
  • When pasting into a new workbook, I need it to transpose without formatting.
<code style="margin: 0px; padding: 1px 5px; border: 0px; font-size: 13px; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; white-space: pre-wrap; background-color: rgb(239, 240, 241);">Sub CSVFile() Range("B2:EL2").Select Selection.Copy Workbooks.Add Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=True Sheets("Sheet2").Select Application.CutCopyMode = False ActiveWindow.SelectedSheets.Delete Sheets("Sheet3").Select ActiveWindow.SelectedSheets.Delete ActiveWorkbook.SaveAs Filename:="C:\MGA\Datasets\Book3.csv", FileFormat:= _ xlCSV, CreateBackup:=False End Sub</code>
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

Forum statistics

Threads
1,216,095
Messages
6,128,795
Members
449,468
Latest member
AGreen17

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