View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default VBA code for sending cells B6:J10 to text file.

Sub MakeCSV()
Dim sh As Worksheet
Set sh = ActiveSheet
Workbooks.Add Template:=xlWBATWorksheet
sh.Range("B6:J10").Copy Destination:= _
ActiveWorkbook.Worksheets(1).Range("A1")
ActiveWorkbook.SaveAs Filename:="C:\MyCSV\" & _
Format(Now, "yymmdd_hh_mm") & ".csv", _
FileFormat:=xlCSV
ActiveWorkbook.Close SaveChanges:=False
End Sub


--
Regards,
Tom Ogilvy




"lothario" wrote in message
...
Hi,

Can you show me VBA code that copies contents of cells B6:J10 into a
plain text file?
By contents I mean the actual data and not the formulas, etc.

I cannot use "Save As" CSV because this data changes often so I need to
automate this process.


Thanks,
Luther



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/