ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   save sheet as "sheetname.txt" (https://www.excelbanter.com/excel-programming/336522-save-sheet-sheetname-txt.html)

igorek

save sheet as "sheetname.txt"
 
Hello,
I have a file that contains multiple sheets. I'd like to be able to save
sheets from 5 to 10 as individual files in the .txt format with the name of
the sheets.

thank you
Igor

Tom Ogilvy

save sheet as "sheetname.txt"
 
for i = 5 to 10
worksheets(i).copy
Activeworkbook.SaveAs activesheet.Name & ".xls"
Activeworkbook.Close SaveChanges:=False
Next

--
Regards,
Tom Ogilvy

"igorek" wrote in message
...
Hello,
I have a file that contains multiple sheets. I'd like to be able to save
sheets from 5 to 10 as individual files in the .txt format with the name

of
the sheets.

thank you
Igor




igorek

save sheet as "sheetname.txt"
 
Tom,

While your code does save file as .txt, it does not actually ask Excel for
any specific txt format (text delimited or OS/2 Mac).
Is there a way to specify it?

Thank you
Igor

Tom Ogilvy

save sheet as "sheetname.txt"
 
Sorry, I missed the .txt in your post. (bad eyes).

for i = 5 to 10
worksheets(i).copy
Activeworkbook.SaveAs activesheet.Name & ".txt" FileFormat:=xlText
Activeworkbook.Close SaveChanges:=False
Next

also xlCSV and others - see excel vba help on FileFormat

--
Regards,
Tom Ogilvy


"igorek" wrote in message
...
Tom,

While your code does save file as .txt, it does not actually ask Excel for
any specific txt format (text delimited or OS/2 Mac).
Is there a way to specify it?

Thank you
Igor





All times are GMT +1. The time now is 11:02 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com