Hi All,
With help of you I can start a macro by selecting a file.
fileToOpen = Application.GetOpenFilename("Text Files (*.dat), *.dat")
Workbooks.OpenText FileName:=fileToOpen
I also found data on how many files are in the current directory.
With Application.FileSearch
.NewSearch
.LookIn = "d:excel"
.FileName = "run"
.MatchTextExactly = True
End With
With Application.FileSearch
If .Execute() > 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
For i = 1 To .FoundFiles.Count
MsgBox .FoundFiles(i)
Next i
Else
MsgBox "There were no files found."
End If
End With
Now I want to combine these two functions. So I can import all the data from a selected directory and import them in Excel.
Thanks.
With help of you I can start a macro by selecting a file.
fileToOpen = Application.GetOpenFilename("Text Files (*.dat), *.dat")
Workbooks.OpenText FileName:=fileToOpen
I also found data on how many files are in the current directory.
With Application.FileSearch
.NewSearch
.LookIn = "d:excel"
.FileName = "run"
.MatchTextExactly = True
End With
With Application.FileSearch
If .Execute() > 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
For i = 1 To .FoundFiles.Count
MsgBox .FoundFiles(i)
Next i
Else
MsgBox "There were no files found."
End If
End With
Now I want to combine these two functions. So I can import all the data from a selected directory and import them in Excel.
Thanks.