Sub IMPORT ()
Dim fichier, nom$, nom2$, Mybook, WBKSource, WBKSource2 As Workbook
' sélectionne et copie la feuille Rejets du fichier sélectionné
' et la colle dans la feuille avant la feuille Synthese
With Application.FileDialog(msoFileDialogOpen) '
.Title = "Choisissez le fichier où les Rejets sont comptabilisés"
.Filters.Clear
.Filters.Add "Fichier Excel", "*.xlsx*"
.AllowMultiSelect = False
If .Show <> 0 Then
nom = .SelectedItems(1)
Set WBKSource = Workbooks.Open(nom) ' mon petit bout à moi ;-)
With WBKSource
.Sheets("Rejets").Copy before:=Mybook.Sheets("Synthese")
.Close False
End With
Else
MsgBox "Aucun fichier n'a été sélectionné", , "Erreur": Exit Sub
End If
End With
' sélectionne et copie la feuille Totaux du fichier sélectionné
' et la colle dans la feuille avant la feuille Synthese
With Application.FileDialog(msoFileDialogOpen) '
.Title = "Choisissez le fichier où les totaux sont comptabilisés"
.Filters.Clear
.Filters.Add "Fichier Excel", "*.xlsx*"
.AllowMultiSelect = False
If .Show <> 0 Then
nom2 = .SelectedItems(1)
Set WBKSource2 = Workbooks.Open(nom2) ' mon petit bout à moi ;-)
With WBKSource2
.Sheets("Totaux").Copy before:=Mybook.Worksheets("Synthese")
.Close False
End With
Else
MsgBox "Aucun fichier n'a été sélectionné", , "Erreur": Exit Sub
End If
End With
End Sub