Hi,
I am trying to export each range of an excel document to txt.
The information in column "A" is the title and column "B-D" is the information.
Right now I can only get cell B to export with "Offset( , 1)"
I tired using the & function to populate columns C and D but I am getting an object error.
Any suggestions?
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:\Users\A9C4VZZ\Desktop\Test"
Set oSh = Sheet1
Set oFS = CreateObject("Scripting.Filesystemobject")
For Each rArticleName In oSh.UsedRange.Columns("A").Cells
Set rDisclaimer = rArticleName.Offset(, 1) & "" & rArticleName.Offset(, 2) & rArticleName.Offset(, 3)
'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
Bookmarks