Hi Robin, The Code below looks for a file name or part of a file name to
import from a csv file. Each import will be the entire file and will be list
under the previous one in your worksheet Try this and post back if you have
anymore issues.
Sub GetEm()
Dim FolderPath As String
Dim objFSO As Object
Dim objFolder As Object
Dim colFiles As Object
Dim objFile As Object
Dim MyCriteria As String
Dim ipBox As String
Dim ipBoxMessage As String
Dim ipBoxTitle As String
Dim i As Variant
ipBoxMessage = "Type your Message Here"
ipBoxTitle = "Your Title Here"
ipBox = InputBox(ipBoxMessage, ipBoxTitle)
MyCriteria = ipBox
FolderPath = "C:\Documents and Settings\username\Desktop\ABC"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(FolderPath)
Set colFiles = objFolder.Files
i = ActiveWorkbook.Worksheets(1).Cells(Cells.Rows.Count,
1).End(xlUp).Offset(1, 0).Row
For Each objFile In colFiles
If InStr(1, objFile, MyCriteria) Then
With ActiveSheet.QueryTables.Add(Connection:="TEXT;" & objFile, _
Destination:=Range("A" & i))
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End If
Next
End Sub