Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Original code is to manual pick the text file to be imported. If I want to
pick 20 files, I have to manual select the 20 files to be import. I cannot use the Control Key to select all the 20 files and import all at once. How should I change the VBA code so that I can select a folder and import all the text files in the folder at once? Thanks. Sub Import() Dim myFileName As Variant Do myFileName = Application.GetOpenFilename( _ filefilter:="Text Files, *.Txt", Title:="Pick a File") If myFileName = False Then MsgBox "Ok, try later" 'user hit cancel Else With ActiveSheet.QueryTables.Add( _ Connection:="TEXT;" & myFileName, _ Destination:=Range("A1")) .Name = "smartscope" .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 = False .TextFileSpaceDelimiter = False .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1) .TextFileTrailingMinusNumbers = True .Refresh BackgroundQuery:=False End With End If Loop Until myFileName = False End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Need to Improve Code Copying/Pasting Between Workbooks | Excel Discussion (Misc queries) | |||
regular code module | Excel Discussion (Misc queries) | |||
can you entre a bar code into a excel cell? | Excel Worksheet Functions | |||
VLOOKUP for Zip Code Ranges | Excel Worksheet Functions | |||
Concatinate a filename | Excel Discussion (Misc queries) |