Sending Data To A Text File

JonRowland

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

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

JonRowland

Active Member
Joined
May 9, 2003
Messages
395
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
395
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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,167,951
Messages
5,856,477
Members
431,817
Latest member
db74

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