I've got an Excel report with a table and I need to export a single column from that table to a txt file. I'm calculating the file name that I want to use for the txt file based on fields in the spreadsheet so I want to use that field as my file name.
The data I want to export is in column S.
The file name I want to use is in cell E5 and contains the file extension of txt as well.
This is what I have so far:
Sub FileNameAsCellContent()
Dim FileName As String
Dim Path As String
Application.DisplayAlerts = False
Path = "C:\temp\"
FileName = Range("E5").Value & ".txt"
ActiveWorkbook.SaveAs Path & FileName, xlTextWindows
Application.DisplayAlerts = True
MsgBox "Export Complete. Click OK to continue"
End Sub
This works but it's exporting the entire worksheet and I only need one column out of the table.
This sub will save the data in Sheet1, column S to a text file.