A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Hi,
try this...
using 'folder picker' method
select One folder ect, ect...
Sub Alpha_A()
'May 20, 2014
Dim myWB As Workbook, wb As Workbook
Set myWB = ThisWorkbook
Dim fPath As String, fName As String
On Error Resume Next
With Application.FileDialog(msoFileDialogFolderPicker)
.Title = "please, select One folder"
.AllowMultiSelect = False
If .Show = True Then
fPath = .SelectedItems(1) & ""
fName = Dir(fPath & "*.txt")
If fName <> "" Then
Application.ScreenUpdating = False
Do Until fName = ""
Application.DisplayAlerts = False
myWB.Sheets(fName).Delete
Application.DisplayAlerts = True
Workbooks.OpenText Filename:=fPath & fName, DataType:=xlDelimited, Tab:=True
Set wb = ActiveWorkbook
wb.Sheets(1).Copy after:=myWB.Sheets(myWB.Sheets.Count)
myWB.Sheets(myWB.Sheets.Count).Name = fName
wb.Close False
fName = Dir()
Loop
Application.ScreenUpdating = True
Else
MsgBox "no files"
End If
Else
MsgBox "Cancel"
End If
End With
End Sub