Sending Data To A Text File

JonRowland

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

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

JonRowland

Active Member
Joined
May 9, 2003
Messages
401
Office Version
  1. 365
Platform
  1. Windows
I'm sending this to the top in case those state side missed it and coudl help
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,351
Office Version
  1. 365
Platform
  1. Windows
Jon

I'm sure it's possible but some further details could be helpful.
 

JonRowland

Active Member
Joined
May 9, 2003
Messages
401
Office Version
  1. 365
Platform
  1. Windows
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
 

pcc

Well-known Member
Joined
Jan 21, 2003
Messages
1,348
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
 

Forum statistics

Threads
1,171,071
Messages
5,873,636
Members
432,989
Latest member
Delayer

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
Top