1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| Option Explicit
Dim objShell As Object, objFolder As Object
Dim Chemin As String, Fichier As String
Sub ImporterDonnées()
[A6:M999].Cells.Clear
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder(&H0&, "Choisir un répertoire", &H1&)
If objFolder Is Nothing Then
MsgBox "Abandon opérateur", vbCritical, "Annulation"
Else
Columns(1).NumberFormat = "dd/mm/yyyy"
Columns(2).NumberFormat = "dd/mm/yyyy"
Columns(3).NumberFormat = "dd/mm/yyyy"
Columns(4).NumberFormat = "00"
Chemin = objFolder.ParentFolder.ParseName(objFolder.Title).Path & "\"
Fichier = Dir(Chemin & "*.xls")
Do While Len(Fichier) > 0
If Fichier <> ThisWorkbook.Name Then
ThisWorkbook.Names.Add "Date", _
RefersTo:="='" & Chemin & "[" & Fichier & "]Fiche de surveillance'!$G$31"
ThisWorkbook.Names.Add "Activité", _
RefersTo:="='" & Chemin & "[" & Fichier & "]Fiche de surveillance'!$A$12"
ThisWorkbook.Names.Add "Presta", _
RefersTo:="='" & Chemin & "[" & Fichier & "]Fiche de surveillance'!$J$7"
ThisWorkbook.Names.Add "C2.2", _
RefersTo:="=WorksheetFunction.CountIfs('" & Chemin & "[" & Fichier & "]Fiche de surveillance'!" & "A15:J16" & ",""2.2"",""C"")"
With Sheets("Fiche")
.[A5] = "=Date"
.[A5].Copy
Sheets("Fiche").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
.[B5] = "=Activité"
.[B5].Copy
Sheets("Fiche").Range("B" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
.[C5] = "=Presta"
.[C5].Copy
Sheets("Fiche").Range("C" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
.[D5] = "=C2.2"
.[D5].Copy
Sheets("Fiche").Range("D" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
End With
End If
Fichier = Dir()
Loop
End If
[A5] = "Date"
[B5] = "Activité"
[C5] = "Prestataire"
[D5] = "Relations Technico-commerciales"
[E5] = "Moyens mis en oeuvre"
[F5] = "Organisation qualité & culture sûreté"
[G5] = "Sécurité & Radioprotection"
[H5] = "Environnement"
[I5] = "Qualité technique du produit"
[J5] = "Délais"
End Sub |
Partager