Writing the contents of cells into a file

MyHero

New Member
Joined
Jan 22, 2009
Messages
26
Hey Folks,

I have a bunch of values in column A, and I need to write (export) the entire column into a file called "ColumnA.dat".

Can someone please help me create an Excel Macro Script that would accomplish that?

Thanks in advance.
 
Thank you all! Seiya's code worked like a charm! Thank you very much!

If I wanted to change the location, based on the contents of a cell, let's say B5, how could I modify the code?

How do you want the data to appear in the new file?

If you want to change the file name just use Range("B6") here instead of the hard-coded "\Column.DAT".

I'm not sure what you mean by the first question, but the results I'm getting are perfect.

Thanks for the Range("B6") tip.

As well, if it's not too much trouble, instead of appending the values, how can I change the code to just replace Column.DAT?

EDIT: I figured this one out by myself, that if I change Append to Output, it does this! :)
 
Last edited:
Upvote 0

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
MyHero

I thought that was pretty straightforward - how do you want the data to appear in the new file?

New line for each piece of data - which appears to be what you want.

Delimited by something, which the code posted is actually doing - using vbCrLf as the delimiter to force a new line.
 
Upvote 0
MyHero

I thought that was pretty straightforward - how do you want the data to appear in the new file?

New line for each piece of data - which appears to be what you want.

Delimited by something, which the code posted is actually doing - using vbCrLf as the delimiter to force a new line.

I want a new line in my .dat file for each row in column A. The code that I have is working perfectly.

I would appreciate if someone could tell me how to modify the code to change the location of the .dat file based on what is in b5.
 
Last edited:
Upvote 0
Add a vairable something like this
Rich (BB code):
Dim myLocation as String
myLocation = "c:\...\...\" & range(b6").value
 
.
.
Open myLocation for append #1
 
Upvote 0

Forum statistics

Threads
1,221,418
Messages
6,159,791
Members
451,589
Latest member
Harold14

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top