pcorcele said:
I have data in col a to e:
I would like a macro that would copy all the data(all the way to the
bottom) and then save that data as a CSV file.
I would appreciate any help I can get with this
If you only have data in the range A:E, I'd say use Claus' solution. But if
you have data outside those columns that you don't want exported, you might
try this instead:
Sub copyA_EtoCSV()
fileout = FreeFile
Open "data.csv" For Output As fileout
For r = 1 To Range("A:E").SpecialCells(xlCellTypeLastCell).Row
Write #fileout, Cells(r, 1).Value, Cells(r, 2).Value, _
Cells(r, 3).Value, Cells(r, 4).Value, Cells(r, 5).Value
Next
Close fileout
End Sub
(This will also work if there's only data in A:E like Claus' code, but this
makes sure that anything beyond column E isn't exported, regardless.)
In both Claus' code and mine above, the path for the CSV needs to be set
appropriately. (Claus shows how to do it based on where the workbook is; I
use a fixed location.)