View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Saving worksheets using a Macro

Option Explicit
Sub testme()

Dim wks As Worksheet
Dim newWks As Worksheet

For Each wks In ActiveWorkbook.Worksheets

wks.Copy 'to a new workbook
Set newWks = ActiveSheet

With newWks
Application.DisplayAlerts = False
.Parent.SaveAs Filename:="C:\TEMP\" & .Name & ".txt", _
FileFormat:=xlText
Application.DisplayAlerts = True
.Parent.Close savechanges:=False
End With
Next wks
End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

lqfong wrote:

Hi,

I have multiple worksheets, and I need to save them in text tab
delimited format.

How can I do this using macros? For example I have 5 worksheets, the
macro would save the worksheets as sheet1.txt, sheet2.txt, sheet3.txt
etc...

Thanks!

--
lqfong
------------------------------------------------------------------------
lqfong's Profile: http://www.excelforum.com/member.php...o&userid=35774
View this thread: http://www.excelforum.com/showthread...hreadid=555908


--

Dave Peterson