Hello. I would like a macro to save a worksheet as a .csv file in a folder on my C drive. The worksheet will vary in size (rows and columns). The sheet must use tabs as a delimiter.
Thanks for your help!
Hello. I would like a macro to save a worksheet as a .csv file in a folder on my C drive. The worksheet will vary in size (rows and columns). The sheet must use tabs as a delimiter.
Thanks for your help!
A CSV file uses commas as delimiters
Activesheet.copy
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs "C:\Myfolder\Myfile.txt", xlText
Application.DisplayAlerts = True
Activeworkbook.Close SaveChanges:=False
--
Regards,
Tom Ogilvy
"Sandeman" wrote:
>
> Hello. I would like a macro to save a worksheet as a .csv file in a
> folder on my C drive. The worksheet will vary in size (rows and
> columns). The sheet must use tabs as a delimiter.
>
> Thanks for your help!
>
>
> --
> Sandeman
> ------------------------------------------------------------------------
> Sandeman's Profile: http://www.excelforum.com/member.php...o&userid=32440
> View this thread: http://www.excelforum.com/showthread...hreadid=529220
>
>
Thanks Tom. Doesn't appear to work though as I get an error stating some of the cells contain more than 255 characters, which stops the macro in its tracks. Is there a workaround or another option?
Maybe
Dim wks As Worksheet
Dim newWks As Worksheet
Set wks = ActiveSheet
wks.Copy
Set newWks = ActiveSheet
wks.Cells.Copy
newWks.Range("a1").PasteSpecial Paste:=xlPasteValues
Application.DisplayAlerts = False
newWks.Parent.SaveAs "C:\Myfile.txt", xlText
Application.DisplayAlerts = True
newWks.Parent.Close SaveChanges:=False
Sandeman wrote:
>
> Thanks Tom. Doesn't appear to work though as I get an error stating
> some of the cells contain more than 255 characters, which stops the
> macro in its tracks. Is there a workaround or another option?
>
> --
> Sandeman
> ------------------------------------------------------------------------
> Sandeman's Profile: http://www.excelforum.com/member.php...o&userid=32440
> View this thread: http://www.excelforum.com/showthread...hreadid=529220
--
Dave Peterson
That's the ticket. Thanks Dave.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks