M
Mohan
Hi
I need to export one colum from Excel to CSV. If the total rows are < 65000
then its not a problem. But I need to export about 150K rows from multiple
colum into one CSV file. How can I do this.
Here is my code to export from one column:
The CSV file path (full path) is pecified on a parmsheet. Basically I create
a new workbook and save that as CSV file.
Sub ExportToCSV()
' Save selected range as a CSV text file
Dim ThisBook As Workbook
Dim path As String
Dim lastrow As Double
ExecuteExcel4Macro "echo(false)"
path = ThisWorkbook.Sheets("parmsheet").Range("B2").Value
'
Range("A1").Select
Selection.End(xlDown).Select
lastrow = ActiveCell.Row
'lastrow = ThisWorkbook.Sheets(1).Range("A1").End(xlUp).Select
ThisWorkbook.Sheets(1).Range("A2:A" & lastrow).Select
Set ThisBook = ActiveWorkbook
Selection.Copy
Workbooks.Add
Selection.PasteSpecial Paste:=xlPasteValues ' one of several options used
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=path, FileFormat:=xlCSV
ActiveWorkbook.Close
Application.DisplayAlerts = True
ThisBook.Activate
ThisBook.Worksheets(1).Range("A1").Activate
MsgBox "The CSV file has been created in" & Chr(13) & path, vbOKOnly, "CSV
Export"
End Sub
I need to export one colum from Excel to CSV. If the total rows are < 65000
then its not a problem. But I need to export about 150K rows from multiple
colum into one CSV file. How can I do this.
Here is my code to export from one column:
The CSV file path (full path) is pecified on a parmsheet. Basically I create
a new workbook and save that as CSV file.
Sub ExportToCSV()
' Save selected range as a CSV text file
Dim ThisBook As Workbook
Dim path As String
Dim lastrow As Double
ExecuteExcel4Macro "echo(false)"
path = ThisWorkbook.Sheets("parmsheet").Range("B2").Value
'
Range("A1").Select
Selection.End(xlDown).Select
lastrow = ActiveCell.Row
'lastrow = ThisWorkbook.Sheets(1).Range("A1").End(xlUp).Select
ThisWorkbook.Sheets(1).Range("A2:A" & lastrow).Select
Set ThisBook = ActiveWorkbook
Selection.Copy
Workbooks.Add
Selection.PasteSpecial Paste:=xlPasteValues ' one of several options used
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=path, FileFormat:=xlCSV
ActiveWorkbook.Close
Application.DisplayAlerts = True
ThisBook.Activate
ThisBook.Worksheets(1).Range("A1").Activate
MsgBox "The CSV file has been created in" & Chr(13) & path, vbOKOnly, "CSV
Export"
End Sub