Export a Named range to Tab seperated text file

P

Peter Kamau

I would like to create a macro to export a named range in Excel to a tab
seperated text file, can anyone assist please ?
 
T

Tom Ogilvy

Sub ABC()
Dim bk as Workbook, bk1 as Workbook
Set bk = ActiveWorkbook
Set bk1 = Workbooks.Add(xlWBATWorksheet)
bk.Names("MyRange").Copy bk1.Worksheets(1).Range("A1")
bk1.SaveAs Filename:="C:\Data\MyFile.txt", _
FileFormat:=xlText, CreateBackup:=False
bk1.close SaveChanges:=False
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top