How to export a range of cells on a worksheet to a text file
Sub CreateFile()
Dim sh as Worksheet, sh1 as Worksheet
set sh = Activesheet
workbooks.Add Template:=xlWBATWorksheet
set sh1 = Activesheet
sh.Range("A1:F20").Copy
sh1.Range("A1").PasteSpecial xlValues
Application.DisplayAlerts = False
sh1.parent.SaveAs "C:\Myfolder\Myfile.txt", xlCSV '<== Change
Application.DisplayAlerts = True
End Sub
there are many different formats for text files. You don't say which you
want. Also, specify the full path and name of your file.
--
Regards,
Tom Ogilvy
wrote in message
oups.com...
Can anyone describe how to export the values in range A1 to F20 on
worksheet 'Data' to a text file? The text file will be named
'routes.txt'. The text file already exists, and it should be
overwritten with the new values each time the macro is executed,
rather than the macro appending the values to the text file.
Thanks kindly.
Best Regards,
Joseph
|