Hello,
I have a little problem. I want to import files to excel - different files to different sheets but I cannot manage to set two extensions at once.
I like Excel to import chosen XLSX and CSV to separate sheets. I dont know how to set more than one extension.
Im useing this code to import xls files
best regards
w.
I have a little problem. I want to import files to excel - different files to different sheets but I cannot manage to set two extensions at once.
I like Excel to import chosen XLSX and CSV to separate sheets. I dont know how to set more than one extension.
Im useing this code to import xls files
Code:
Dim xFilesToOpen As Variant
Dim i As Integer
Dim xWb As Workbook
Dim xTempWb As Workbook
Dim xDelimiter As String
Dim xScreen As Boolean
On Error GoTo ErrHandler
xDelimiter = "|"
xFilesToOpen = Application.GetOpenFilename("Wycena i Eru (*.xls), *.xls", , "", , True)
If TypeName(xFilesToOpen) = "Boolean" Then
MsgBox "No files were selected", , ""
GoTo ExitHandler
End If
i = 1
Set xTempWb = Workbooks.Open(xFilesToOpen(i))
xTempWb.Sheets(1).Copy
Set xWb = Application.ActiveWorkbook
xTempWb.Close False
Do While i < UBound(xFilesToOpen)
i = i + 1
Set xTempWb = Workbooks.Open(xFilesToOpen(i))
With xWb
xTempWb.Sheets(1).Move After:=.Sheets(.Sheets.count)
End With
Loop
ExitHandler:
Set xWb = Nothing
Set xTempWb = Nothing
ErrHandler:
best regards
w.