Inside Excel, I have a list of article names in column A, and a disclaimer inside column B. Now for each article in column A, I would like to create a text file, were A is the title of the file and B, the disclaimer, is the contents of the file.
Is this possible?
The idea is that I have several hundred of these, and I would like to make this easier on myself.
If Excel is not ideal for this, can anyone suggest an alternative? (possibly Notepad++ has a feature that can help?)
Start off by opening up the list page that you want to export the rows from and select the rows that you want to export. Then right-mouse-click on the check marks beside the records. When the context menu is displayed, there will be two new options that show up. Export all rows and also Export marked rows.
Open the Excel spreadsheet where you want to save the data and click the Data tab. In the Get External Data group, click From Text. Select the TXT or CSV file you want to convert and click Import.
Sub Export_Files()
Dim sExportFolder, sFN
Dim rArticleName As Range
Dim rDisclaimer As Range
Dim oSh As Worksheet
Dim oFS As Object
Dim oTxt As Object
'sExportFolder = path to the folder you want to export to
'oSh = The sheet where your data is stored
sExportFolder = "C:\Disclaimers"
Set oSh = Sheet1
Set oFS = CreateObject("Scripting.Filesystemobject")
For Each rArticleName In oSh.UsedRange.Columns("A").Cells
Set rDisclaimer = rArticleName.Offset(, 1)
'Add .txt to the article name as a file name
sFN = rArticleName.Value & ".txt"
Set oTxt = oFS.OpenTextFile(sExportFolder & "\" & sFN, 2, True)
oTxt.Write rDisclaimer.Value
oTxt.Close
Next
End Sub
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With