Saving a range of data as a new file


Posted by Alex Williams on January 24, 2000 2:50 PM

Can you save a selected range into a file of its own?

For example, if I have a huge file, and I just want to
save one section of it as a text file, is there a
way to highlight just that section and save it as
another file?

-alex

Posted by Celia on January 24, 2000 3:41 PM


Alex
Try creating a macro with the macro recorder.
Celia

Posted by Phil Ruhnow on January 26, 2000 1:47 AM


Obvious is the copy paste, or copy, paste special value.
Next option, link, then copy paste.
Next option, save file as another name, then copy paste special.



Posted by Ivan Moala on January 28, 2000 6:44 AM

Alex
To write a range as a text file try this;

Sub WriteRangeCellsText()
Dim MyRg As Range
Dim TextCell As Range
Dim TxtToWrite As String

Set MyRg = Range("a1:D1")
For Each TextCell In MyRg
TxtToWrite = TxtToWrite & TextCell.Text
Next
Open "C:\Windows\Desktop\Test.txt" For Output As #1
Print #1, TxtToWrite
Close #1

End Sub

You will probably want to change the selection
via the inputbox method to select your range.

Ivan