Ismailovech
New Member
Hi All,
I have a code that enables me to save selected column data from excel to a new .txt file, I need a help to update the code to save the files automatically to a specific folder path and rename the files automatically as a function of the selected data (row and column) header.
Is that possible?!
Thanks,
Ahmed
I have a code that enables me to save selected column data from excel to a new .txt file, I need a help to update the code to save the files automatically to a specific folder path and rename the files automatically as a function of the selected data (row and column) header.
Is that possible?!
Code:
Sub ExportRangetoFile()
'Update 20130913
Dim wb As Workbook
Dim saveFile As String
Dim WorkRng As Range
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set wb = Application.Workbooks.Add
WorkRng.Copy
wb.Worksheets(1).Paste
saveFile = Application.GetSaveAsFilename(fileFilter:="Text Files (*.txt), *.txt")
wb.SaveAs Filename:=saveFile, FileFormat:=xlText, CreateBackup:=False
wb.Close
Application.CutCopyMode = False
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
Thanks,
Ahmed
Last edited: