Solved export data from excel to text file

October 13, 2017 at 08:35:53
Specs: Windows 10
I am wanting to get the data from Column "A" to be the title of the text file. NOTE: there are different Plugin ID's in column "A" each to have its on text file. Next from Column "G" I need the name of the computer system that is associated with the Plugin ID from Column "A" in the text file.

I'm not to sure how to do this. any guidance would be helpful.


See More: export data from excel to text file

Reply ↓  Report •

#1
October 14, 2017 at 16:56:00
You may be better off using a free program as we don't know your version of Excel.

Excel Converter
http://www.softpedia.com/get/Office...
http://excelconverter.svelte-projec...

Exportizer
http://www.softpedia.com/get/Intern...
http://www.vlsoftware.net/exportizer/

message edited by Johnw


Reply ↓  Report •

#2
October 17, 2017 at 06:46:30
✔ Best Answer
Something like this will work. it will take each item is column A and create a text file with the name of the file being the text in each of the cells in Row A, then it will write the content from column G into it..


Sub CreateFiles()
    
    Dim Bcell As Range
    Dim FolderPath As String
    Dim Fs As Object
    Dim NewFile As Object
    
    FolderPath = "C:\Test\"
    
    For Each Bcell In Range("A1", Range("A" & Rows.Count).End(xlUp))
        
        Set Fs = CreateObject("Scripting.FileSystemObject")
        Set NewFile = Fs.CreateTextFile(FolderPath & Bcell & ".txt", True)
        NewFile.WriteLine (Bcell.Offset(0, 6))
        NewFile.Close
    
    Next Bcell
            
End Sub

message edited by AlwaysWillingToLearn


Reply ↓  Report •

#3
October 19, 2017 at 14:00:58
in the environment that I am in I cannot download and use third party programs. I must create a script to do this job.

the office version is office 2013


Reply ↓  Report •

Related Solutions

#4
October 20, 2017 at 03:03:11
For the solution i have offered you do not need any third party tools, vba is a part of ms office and therefore can be run within Excel.


Reply ↓  Report •

#5
October 20, 2017 at 08:42:59
so I understand correctly I can run this vba script and it will open the xlsx file that is in the folder designated in the script and copy the data from the perspective cells listed within the script?

Reply ↓  Report •

#6
October 25, 2017 at 06:24:11
You need to

1) Open the Excel file that contains your data
2) Hold down 'Alt' then press 'F11'
When the new window (VBA IDE) opens on the top left you will see a series of objects (Sheet1, Sheet2) etc
3) Find the sheet that corresponds to the sheet in which your data is stored.
4) Double click on that object (Eg Sheet1) and paste the code.

Now place the cursor over the line

Sub CreateFiles()

press 'F8' then 'F5'

we can remove a lot of this with a simple command button, so if you need I can add the button onto your workbook, if you PM me I can send you my email address, if you wish to learn how to do this just ask..

Once you have press F8 and F5 the code will execute and create the outputs. Make sure you change the path from

"C:\Test\"
in the code to whatever you like, ensure you include the "\" at the end of your path.

Reply ↓  Report •

Ask Question