View Full Version : [SOLVED:] Export data to text files according to fields
YasserKhalil
07-15-2017, 02:47 AM
Hello everyone
I have a template text file on which base I need to export data in Sheet in column A:B to text files
The exported output text file would be the same as Template text file
And at HTT "" > between quotation marks put the data in column A and after that put in new line the second column
As for each row (column A:B) will be exported to separate text file
I have attached a sample of the desired output so as to make it clearer
Thanks advanced for help
Option Explicit
Sub test()
Dim myTXT As String
Dim i As Long
Dim s As String
For i = 1 To Cells(Rows.Count, 1).End(xlUp).Row
myTXT = ActiveWorkbook.Path & "\Row" & i & ".txt"
s = "[Hello ""World""]" & vbLf & "[Please ""Help""]" & vbLf _
& "[Thanks """"]" & vbLf & "[HTT """
s = s & Cells(i, 1).Value & "]" & vbLf & vbLf & Cells(i, 2).Value
Open myTXT For Output As #1
Print #1, s
Close #1
Next
End Sub
YasserKhalil
07-15-2017, 06:36 AM
That's fantastic and wonderful
Exactly as I was searching for
How can I change the extension manually (say instead of "txt" I would like to make extension "csv") .. I don't ask about convert but just change the extension of the exported file
YasserKhalil
07-15-2017, 06:41 AM
I have noticed the extension in this line
myTXT = ActiveWorkbook.Path & "\Row" & i & ".txt"
And I changed and that worked well
Thanks a lot for great help
YasserKhalil
07-15-2017, 06:45 AM
Why can't I give reputation points in this forum?
A message appears saying "You must spread some reputation around before giving it to mana again" ..
And I can't give to anyone. Is this a bug or what?
mdmackillop
07-15-2017, 09:16 AM
Why can't I give reputation points in this forum?
I don't know here they appear or if they even work. Try asking Admin using Contact Us. Meantime I'll give Mana a well earned point.
Regards
MD
YasserKhalil
07-15-2017, 09:34 AM
Thanks a lot MD
I have asked Admin and waiting for reply ... Hope it will be more flexible
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.