View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Steve Yandl Steve Yandl is offline
external usenet poster
 
Posts: 284
Default Copy Cell Content to CSV file

Here is one option.

This subroutine assumes that a folder named "C:\Test" already exists on the
system. It will save the CSV file to that folder as myData.csv

_____________________________________

Sub ExportCSV()

strFldrPath = "C:\Test"

Set FSO = CreateObject("Scripting.FileSystemObject")
Set objCSVfile = FSO.CreateTextFile(strFldrPath & "\myData.csv")

For R = 1 To 100
strRecord = Cells(R, 1).Value
For C = 2 To 7
strRecord = strRecord & "," & Cells(R, C)
Next C
objCSVfile.WriteLine strRecord
Next R

objCSVfile.Close

Set FSO = Nothing

End Sub

_____________________________________

Steve



"Joe K." <Joe wrote in message
...

I have a spreadsheet with a worksheet that I need to create a simple macro
to copy the contents from cells a1 to g100 to a csv file format.

Please help me with this macro.

Thanks,