Sending Data To A Text File

JonRowland

Active Member
Joined
May 9, 2003
Messages
416
Office Version
  1. 365
Platform
  1. Windows
Can anyone help, I can't seem to find an easy solution.

I am looking to have a macro that will select copy some text and then send it into a text file.

What VBA would I need to open and paste into the text file?

Cheers

Jon
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
I'm sending this to the top in case those state side missed it and coudl help
 
Upvote 0
Jon

I'm sure it's possible but some further details could be helpful.
 
Upvote 0
Hi,

I try my best as explaining what I am looking to do.

The user enters some text.
The text entered is user to create some SQL for a database query. Currently this is copied out manually into a SQL import file which contains some other SQL needed to the query.
What I want is for Excel to output column C into a text file, saving on the user from manually copying it.

Hope that's clear.

Jon
 
Upvote 0
try this or adapt to suit
Code:
Sub write_to_file()
Dim f As Integer
f = FreeFile
fname = "c:\youfile.txt" ' change to suit
   Open fname For Output As f
   c = 3
   r = 1
   Do Until IsEmpty(Cells(r, c))
          Write #f, Cells(r, c)
        r = r + 1
        Loop
         Close #f
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,867
Members
449,053
Latest member
Mesh

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