View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Marco To Save Column A7 As A .txt File.

Chris,

I don't understand why that is happening.
Do you mean the word "Script" appears in the textfile?
Do you have the word "Script" as a header in column D?

Mike

"Chris" wrote:

Hi Mike,

thanks for your reply.
this script works perfectly, apart from one littile problem.
when I click the button the txt file is created but at the top it says :
Script

is there anyway of deleting this?

Regards,
Chris

"Mike H" wrote:

Chris,

Right click your sheet tab, view code and paste this in. To create a button
open the 'Forms' toolbar click on the button and create one on the desktop.
In the popup window navigate to the macro.

Sub savetext()
Lastrow = Cells(Cells.Rows.Count, "D").End(xlUp).Row
Set myrange = Range("D1:D" & Lastrow)
filenum = FreeFile
Open "C:\myfile.txt" For Append As filenum
For Each c In myrange
Print #filenum, c.Text
Next
Close #filenum
End Sub

Mike

"Chris" wrote:

Hey All,

Is it possible to set up a macro where only one column can be saved as a
text file?

i.e.

Column A,B,C,D is full of data, I would like to save Column D's information
into a txt file by a click of a button onto my desktop.

Any help would be great!

Regards,
Chris