I need button to seach in folders if there is a XLSX or CSV file and import to a table, i were trying this code for each folder.
Sub Import_files2me()
Const strPath As String = "C:\COCFAT\99_input\CDT" 'Directory Path 1
Dim strFile As String 'Filename
Dim strFileList() As String 'File Array
Dim intFile As Integer 'File Number
'Loop through the folder & build file list
strFile = Dir(strPath & "*.xlsx")
While strFile <> ""
'add files to the list
intFile = intFile + 1
ReDim Preserve strFileList(1 To intFile)
strFileList(intFile) = strFile
strFile = Dir()
Wend
'see if any files were found
If intFile = 0 Then
MsgBox "Não existem ficheiros na pasta CDT"
If MsgBox("Quer continuar?", vbYesNo + vbQuestion) = vbYes Then
Else
Exit Sub
End If
End Sub
Sub Import_files2me()
Const strPath As String = "C:\COCFAT\99_input\CDT" 'Directory Path 1
Dim strFile As String 'Filename
Dim strFileList() As String 'File Array
Dim intFile As Integer 'File Number
'Loop through the folder & build file list
strFile = Dir(strPath & "*.xlsx")
While strFile <> ""
'add files to the list
intFile = intFile + 1
ReDim Preserve strFileList(1 To intFile)
strFileList(intFile) = strFile
strFile = Dir()
Wend
'see if any files were found
If intFile = 0 Then
MsgBox "Não existem ficheiros na pasta CDT"
If MsgBox("Quer continuar?", vbYesNo + vbQuestion) = vbYes Then
Else
Exit Sub
End If
End Sub