Please please help me work out what is wrong with the below code. I simply want to select several files and process them into one worksheet in the same way; i recorded the processing, modified it to include and array in Y and put multiselect to true but it simply won't get past the GetOpenFilename part
Code:Private Sub CommandButton1_Click() Dim X As Variant 'Opens the dialog X = Application.GetOpenFilename("CSV Files (*.csv),*.csv,Text Files (*.txt),*.txt", 4, "Select Files", , True) 'Loops through every file that is selected and opens each one For Y = 1 To UBound(X) With ActiveSheet.QueryTables.Add(Connection:= _ "X(Y)", Destination _ :=Range("1,(Y+(Y-1))")) .Name = "X(Y)" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .RefreshOnFileOpen = False .BackgroundQuery = True .RefreshStyle = xlInsertDeleteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = True .TextFilePromptOnRefresh = False .TextFilePlatform = xlMacintosh .TextFileStartRow = 2 .TextFileParseType = xlDelimited .TextFileTextQualifier = xlTextQualifierDoubleQuote .TextFileConsecutiveDelimiter = True .TextFileTabDelimiter = True .TextFileSemicolonDelimiter = False .TextFileCommaDelimiter = True .TextFileSpaceDelimiter = True .TextFileOtherDelimiter = """" .TextFileColumnDataTypes = Array(9, 5, 9, 1, 9, 9) .Refresh BackgroundQuery:=False .UseListObject = False End With Next Y End Sub Private Sub UserForm_Click() End Sub




Reply With Quote