Hi,
I am having a hard time trying to create a vba code to perform a specific task.
I want the user to be able to select the folder where all the text files are located.
Then, have the VBA code to convert multiple text files into excel. So each text file will have its own excel spreadsheet (I do not want to combine the text files). And then close the text files and excel spreadsheets in that same folder that was initially selected by the user.
The folder name changes every month and so does the text file titles.
I was able to use the Macro to convert a text file into an excel spreadsheet, but I don't know how to assign the variables and be able to do that for each text file (looping).
Macro to convert text file into excel spreadsheet:
app.Workbooks.OpenText Filename:=myFile, Origin:=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _
Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), _
Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1), Array(8, 1), _
Array(9, 1), Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1)), _
TrailingMinusNumbers:=True
I am having a hard time trying to create a vba code to perform a specific task.
I want the user to be able to select the folder where all the text files are located.
Then, have the VBA code to convert multiple text files into excel. So each text file will have its own excel spreadsheet (I do not want to combine the text files). And then close the text files and excel spreadsheets in that same folder that was initially selected by the user.
The folder name changes every month and so does the text file titles.
I was able to use the Macro to convert a text file into an excel spreadsheet, but I don't know how to assign the variables and be able to do that for each text file (looping).
Macro to convert text file into excel spreadsheet:
app.Workbooks.OpenText Filename:=myFile, Origin:=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _
Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), _
Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1), Array(8, 1), _
Array(9, 1), Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1)), _
TrailingMinusNumbers:=True