MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.
Sub LoopFiles2() Static MyFileName, MyPath As String Dim sheetname As String Dim FileType As Integer With Application.FileDialog(msoFileDialogFolderPicker) If .Show = 0 Then Exit Sub Else MyPath = .SelectedItems(1) & "\" End If End With MyFileName = Dir(MyPath & "*.xml") Application.DisplayAlerts = False Do While Len(MyFileName) > 0 chksheetname = LCase(Mid$(MyFileName, 14)) If chksheetname = "chikeysitems28" Then FileType = 1 sheetname = Split(Mid$(MyFileName, 14), ".")(0) Else chksheetname = LCase(Mid$(MyFileName, 16)) If chksheetname = "chiparameters28" Then sheetname = Split(Mid$(MyFileName, 16), ".")(0) FileType = 2 Else FileType = 3 sheetname = Split(Mid$(MyFileName, 20), ".")(0) End If End If With Sheets.Add .Name = sheetname With .QueryTables.Add(Connection:= _ "FINDER;" & MyPath & MyFileName, _ Destination:=.Range("A1")) .Name = .Parent.Name End With ThisWorkbook.XmlImport URL:=MyPath & MyFileName, _ ImportMap:=Nothing, _ Overwrite:=True, _ Destination:=.Range("A1") End With MyFileName = Dir Loop Application.DisplayAlerts = True End Sub
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.