Sending Data To A Text File

JonRowland

Active Member
Joined
May 9, 2003
Messages
417
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

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
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,215,239
Messages
6,123,816
Members
449,127
Latest member
Cyko

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