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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
| Option Explicit
Private Const Graph9 As String = "\\Eur-tou-srv\teams\TOU_Public\TOU-EHS\Observations EHS\\ImageTemp9.gif"
Private Const Graph10 As String = "\\Eur-tou-srv\teams\TOU_Public\TOU-EHS\Observations EHS\\ImageTemp10.gif"
Private Sub UserForm_Initialize()
Dim nom_opérateur As Variant
'Récupération des données "combobox1 et 2" de l'USF "Indic_suivi_opérateurs"
Label6.Caption = Indic_suivi_opérateurs.ComboBox2.Value
Label7.Caption = Indic_suivi_opérateurs.ComboBox1.Value
nom_opérateur = Range("Liste!F2").End(xlDown).Address
ComboBox3.RowSource = "Liste!F2:" & nom_opérateur
ComboBox3.ListIndex = 0
' Activation de la fenêtre "Graph Machines"
Worksheets("Graph Opérateurs").Activate
Worksheets("Graph Opérateurs").Visible = False
'Supprime l'image temportaire si elle existe
If Dir(Graph9) <> "" Then Kill Graph9
If Dir(Graph10) <> "" Then Kill Graph10
End Sub
Private Sub Afficher_graph_Click()
Lvw_opérateur
Application.ScreenUpdating = False
ActiveWorkbook.RefreshAll
' Activation de la fenêtre "Indicateurs Machines"
Worksheets("Indicateurs Opérateurs").Activate
On Error Resume Next
'Activation des champs des filtres du "TCD16"
ActiveSheet.PivotTables("TCD16").PivotFields("ANNEE").ClearAllFilters
ActiveSheet.PivotTables("TCD16").PivotFields("ANNEE").CurrentPage = Label6.Caption
ActiveSheet.PivotTables("TCD16").PivotFields("SECTION").ClearAllFilters
ActiveSheet.PivotTables("TCD16").PivotFields("SECTION").CurrentPage = Label7.Caption
ActiveSheet.PivotTables("TCD16").PivotFields("OPERATEUR").ClearAllFilters
ActiveSheet.PivotTables("TCD16").PivotFields("OPERATEUR").CurrentPage = Indic_détails_opérateur.ComboBox3.Value
On Error Resume Next
'Activation des champs des filtres du "TCD17"
ActiveSheet.PivotTables("TCD17").PivotFields("ANNEE").ClearAllFilters
ActiveSheet.PivotTables("TCD17").PivotFields("ANNEE").CurrentPage = Label6.Caption
ActiveSheet.PivotTables("TCD17").PivotFields("SECTION").ClearAllFilters
ActiveSheet.PivotTables("TCD17").PivotFields("SECTION").CurrentPage = Label7.Caption
ActiveSheet.PivotTables("TCD17").PivotFields("OPERATEUR").ClearAllFilters
ActiveSheet.PivotTables("TCD17").PivotFields("OPERATEUR").CurrentPage = Indic_détails_opérateur.ComboBox3.Value
'Définit les 3 graphiques de la feuille "Graph Opérateurs"
Worksheets("Graph Opérateurs").ChartObjects("Graphique 9").Chart.Export Filename:=Graph9, filtername:="GIF"
Worksheets("Graph Opérateurs").ChartObjects("Graphique 10").Chart.Export Filename:=Graph10, filtername:="GIF"
'exporte le graphique au format image
'Affiche l'image dans l'UserForm
Image9.Picture = LoadPicture(Graph9)
Image10.Picture = LoadPicture(Graph10)
Exit Sub
'Masque la feuille "Indicateurs Machines"
Worksheets("Indicateurs Opérateurs").Visible = False
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then Cancel = True
End Sub
Sub Lvw_opérateur()
Dim Plage As Range, c As Range, i As Integer
'positionnement du premier filtre
With Sheets("Rapport")
Set Plage = .Range(.[A26], .Cells(.Rows.Count, 15).End(xlUp))
.AutoFilterMode = False
Plage.AutoFilter 6, Criteria1:=ComboBox3.Value, Operator:=xlFilterValues
Plage.AutoFilter 15
With .AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End With
'remplissage de la listview
With ListView1
Set Plage = Sheets(6).AutoFilter.Range.Offset(1)
Set Plage = Plage.Resize(Plage.Rows.Count - 1, 1)
Set Plage = Plage.SpecialCells(xlCellTypeVisible)
With .ColumnHeaders
'suppression des entêtes de colonne
.Clear
'détermination de l'intitulé et de la largeur des colonnes
.Add , , "Date", 50
.Add , , "Thème", 50
.Add , , "Rep", 30
.Add , , "Déscription des écarts", 200
.Add , , "Actions correctives", 200
.Add , , "Pilote", 50
.Add , , "Délai", 50
.Add , , "Avct", 30
End With
'on affiche les entêtes de colonne
.HideColumnHeaders = False
'alimentation de la listview pour chaque ligne de la zone filtrée
For Each c In Plage
'ajout d'une ligne et de la valeur de la première colonne
.ListItems.Add , , c.Value
With .ListItems(.ListItems.Count)
'ajout de la valeur de la deuxième colonne
.ListSubItems.Add , , c.Offset(, 8).Value
.ListSubItems.Add , , c.Offset(, 9).Value
.ListSubItems.Add , , c.Offset(, 10).Value
.ListSubItems.Add , , c.Offset(, 11).Value
.ListSubItems.Add , , c.Offset(, 12).Value
.ListSubItems.Add , , c.Offset(, 13).Value
.ListSubItems.Add , , c.Offset(, 14).Value
.ListSubItems.Add , , c.Offset(, 15).Value
End With
Next c
End With
'Spécifie l'affichage en mode "Détails"
ListView1.View = lvwReport
ListView1.Gridlines = True
ListView1.FullRowSelect = True
Exit Sub
End Sub
Private Sub Fermer_graph_Click()
'Supprime l'image temporaire si elle existe
If Dir(Graph9) <> "" Then Kill Graph9
If Dir(Graph10) <> "" Then Kill Graph10
Unload Me
End Sub |