linoutandabout
New Member
- Joined
- Feb 27, 2010
- Messages
- 10
I have some daily text files in a folder (so about 30 of them each month), which in the end of month, I need to open them up in excel, format them so that I can use the information for my analysis.
I would like to create a macro, to quickly open them all up at once and save them each individually in .xls or .xlsm format.
I am new to VBA and after some research online, I was able to have the files open with the following code. but now I don't know how to proceed further to save them one by one with the same name but in .xls or .xlsm format.
Would really appreciate your help on this!
Thanks!
Sub Opentxtfiles()
Dim MyFolder As String
Dim myfile As String
Dim folderName As String
With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = False
If .Show = -1 Then
folderName = .SelectedItems(1)
End If
End With
myfile = Dir(folderName & "\*.txt")
Do While myfile <> ""
Workbooks.OpenText Filename:=folderName & "\" & myfile
myfile = Dir
Loop
End Sub
I would like to create a macro, to quickly open them all up at once and save them each individually in .xls or .xlsm format.
I am new to VBA and after some research online, I was able to have the files open with the following code. but now I don't know how to proceed further to save them one by one with the same name but in .xls or .xlsm format.

Would really appreciate your help on this!
Thanks!
Sub Opentxtfiles()
Dim MyFolder As String
Dim myfile As String
Dim folderName As String
With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = False
If .Show = -1 Then
folderName = .SelectedItems(1)
End If
End With
myfile = Dir(folderName & "\*.txt")
Do While myfile <> ""
Workbooks.OpenText Filename:=folderName & "\" & myfile
myfile = Dir
Loop
End Sub