ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   macro to export a range to a text file? (https://www.excelbanter.com/excel-programming/364768-macro-export-range-text-file.html)

[email protected]

macro to export a range to a text file?
 
Greetings experts...

Is it possible to export the contents of a specified range to a text
file?

The worksheet will be protected and the cells locked. The range to
export will always be the same. The user will not select the range,
the range should already be defined in the macro.

The macro should not save the entire workbook or worksheet as a text
file, nor should it export the entire workbook or worksheet to a text
file, nor should it prompt the user for any input whatsoever.

Simply the contents of range $A:$5: $B:$20 ---- text file. I searched
and searched for a known solution, but could not find one, hence my
post here.

If a delimiter is required, a simple space or tab will suffice.

Thanks kindly.

(Please note: I reviewed the excellent work of Pearson, Patterson,
Peo, Max, and others, but their examples are not quite what I need, and
I'm unsure of how to modify their examples to fit my needs.)

J


[email protected]

macro to export a range to a text file?
 
I wrote:

Simply the contents of range $A:$5: $B:$20 ---- text file.


Er, that should be $A$5:$B$20

Pardon the syntax mistake.

J


buster

macro to export a range to a text file?
 
I was unable to find a solution that would directly export a range, but I
have a workaround you might try. Code the macro to insert a new worksheet
and copy/paste-values the range to export to the new worksheet's A1. Export
the new worksheet using FileFormat property xlTextWindows then delete the
inserted worksheet. [I used xlTextWindows as does not the add quote marks
like xlTextMSDOS.]

It may not be graceful, but it does what you want.

" wrote:

Greetings experts...

Is it possible to export the contents of a specified range to a text
file?

The worksheet will be protected and the cells locked. The range to
export will always be the same. The user will not select the range,
the range should already be defined in the macro.

The macro should not save the entire workbook or worksheet as a text
file, nor should it export the entire workbook or worksheet to a text
file, nor should it prompt the user for any input whatsoever.

Simply the contents of range $A:$5: $B:$20 ---- text file. I searched
and searched for a known solution, but could not find one, hence my
post here.

If a delimiter is required, a simple space or tab will suffice.

Thanks kindly.

(Please note: I reviewed the excellent work of Pearson, Patterson,
Peo, Max, and others, but their examples are not quite what I need, and
I'm unsure of how to modify their examples to fit my needs.)

J



[email protected]

macro to export a range to a text file?
 
Hello,

Have a look he
http://www.erlandsendata.no/english/...atextexportcsv

HTH,
Bernd


buster

macro to export a range to a text file?
 
Scratch the part about xlTextWindows, it does save using the quotes. Sorry.

"Buster" wrote:

I was unable to find a solution that would directly export a range, but I
have a workaround you might try. Code the macro to insert a new worksheet
and copy/paste-values the range to export to the new worksheet's A1. Export
the new worksheet using FileFormat property xlTextWindows then delete the
inserted worksheet. [I used xlTextWindows as does not the add quote marks
like xlTextMSDOS.]

It may not be graceful, but it does what you want.

" wrote:

Greetings experts...

Is it possible to export the contents of a specified range to a text
file?

The worksheet will be protected and the cells locked. The range to
export will always be the same. The user will not select the range,
the range should already be defined in the macro.

The macro should not save the entire workbook or worksheet as a text
file, nor should it export the entire workbook or worksheet to a text
file, nor should it prompt the user for any input whatsoever.

Simply the contents of range $A:$5: $B:$20 ---- text file. I searched
and searched for a known solution, but could not find one, hence my
post here.

If a delimiter is required, a simple space or tab will suffice.

Thanks kindly.

(Please note: I reviewed the excellent work of Pearson, Patterson,
Peo, Max, and others, but their examples are not quite what I need, and
I'm unsure of how to modify their examples to fit my needs.)

J




All times are GMT +1. The time now is 01:27 AM.

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