ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Save range to text file. (https://www.excelbanter.com/excel-programming/400424-save-range-text-file.html)

[email protected]

Save range to text file.
 
I need to create a text file, containing a range of cells in a
worksheet. I recorded the following macro to selct the range, paste
special as text into a seperate worksheet, and save the worksheet
containing the text to a text file. This works, but also saves the
entire workbook as a new workbook in text format. I would like find a
way to export the range directly into a text file, or be able to save
the worksheet caontaing the text without saveing teh entire workbook
as text. I have seen some example here, but they are somewhat
complicated, and I can not get them to out put the range I need
(G15:J25). Can someone suggest a modification to output the range to a
text file without saving the workbook as a text file.

Thanks


Sub Macro1()
'
' Macro1 Macro
'

'
Range("G15:J25").Select
Selection.Copy
Sheets("lookuptable").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ChDir "C:\Users\David\Desktop"
ActiveWorkbook.SaveAs Filename:= _
"C:\Users\David\Desktop\lookuptable.txt", FileFormat _
:=xlText, CreateBackup:=False
Sheets("calibration").Select
End Sub


JE McGimpsey

Save range to text file.
 
You may be able to use the technique shown he

http://www.mcgimpsey.com/excel/textfiles.html

In article .com,
wrote:

I need to create a text file, containing a range of cells in a
worksheet. I recorded the following macro to selct the range, paste
special as text into a seperate worksheet, and save the worksheet
containing the text to a text file. This works, but also saves the
entire workbook as a new workbook in text format. I would like find a
way to export the range directly into a text file, or be able to save
the worksheet caontaing the text without saveing teh entire workbook
as text. I have seen some example here, but they are somewhat
complicated, and I can not get them to out put the range I need
(G15:J25). Can someone suggest a modification to output the range to a
text file without saving the workbook as a text file.

Thanks


Sub Macro1()
'
' Macro1 Macro
'

'
Range("G15:J25").Select
Selection.Copy
Sheets("lookuptable").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ChDir "C:\Users\David\Desktop"
ActiveWorkbook.SaveAs Filename:= _
"C:\Users\David\Desktop\lookuptable.txt", FileFormat _
:=xlText, CreateBackup:=False
Sheets("calibration").Select
End Sub



All times are GMT +1. The time now is 10:35 AM.

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