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
|
Sub triePrenoms()
Dim Nom As String
Dim Ligne As Integer
Dim Sht_Donnees As Worksheet
Set Sht_Donnees = Sheets("Données")
'---------------------------------------
' Definitions des colonnes à récupérer
'----------------------------------------
Dim Col_NoItem As Integer
Col_NoItem = 4
Dim Col_NoCasType As Integer
Col_NoCasType = 5
Dim Col_DateMes As Integer
Col_DateMes = 6
Dim Col_CodeMesure As Integer
Col_CodeMesure = 7
Dim Col_Poids As Integer
Col_Poids = 8
Dim Col_ResultatCorrige As Integer
Col_ResultatCorrige = 9
Dim Col_Resultat As Integer
Col_Resultat = 10
Dim Col_Minimum As Integer
Col_Minimum = 11
Dim Col_Maximum As Integer
Col_Maximum = 12
Dim Col_CodeUnite As Integer
Col_CodeUnite = 13
'---------------------------------------
' Definitions des colonnes de destination
'----------------------------------------
Dim Col_NoItem_desti As Integer
Col_NoItem_desti = 1
Dim Col_NoCasType_desti As Integer
Col_NoCasType_desti = 2
Dim Col_DateMes_desti As Integer
Col_DateMes_desti = 3
Dim Col_CodeMesure_desti As Integer
Col_CodeMesure_desti = 4
Dim Col_Poids_desti As Integer
Col_Poids_desti = 5
Dim Col_ResultatCorrige_desti As Integer
Col_ResultatCorrige_desti = 6
Dim Col_Resultat_desti As Integer
Col_Resultat_desti = 7
Dim Col_Minimum_desti As Integer
Col_Minimum_desti = 8
Dim Col_Maximum_desti As Integer
Col_Maximum_desti = 9
Dim Col_CodeUnite_desti As Integer
Col_CodeUnite_desti = 10
' Ligne du début du tableau généré..
Dim Ligne_desti As Integer
'----------------------------------------
'Colonne contenant les noms..
'----------------------------------------
Dim PlageNon As Range
Set PlageNon = Range("A2:A50")
'----------------------------------------
'Debut du traitement
'----------------------------------------
'Boucle sur cette plage
Sht_Donnees.Activate
For Each cell In PlageNon
Nom = cell.Value
NomPrecedent = cell.Offset(-1).Value
'Changement de nom.. réinitialisation de la variable Ligne_Desti
If Nom <> NomPrecedent And Nom <> "Nom" And Nom <> "" Then
Ligne_desti = 7
End If
'Si l'onglet n'existe pas ..on prévient l'utilisateur
If Not FExist(Nom) And Nom <> "" Then
MsgBox ("La feuille " & Nom & "N'existe pas !")
Else
Sht_Donnees.Activate
'On récupère les données...
Ligne = cell.Row
NoItem = Cells(Ligne, Col_NoItem).Value
NoCasType = Cells(Ligne, Col_NoCasType).Value
DateMes = Cells(Ligne, Col_DateMes).Value
CodeMesure = Cells(Ligne, Col_CodeMesure).Value
Poids = Cells(Ligne, Col_Poids).Value
ResultatCorrige = Cells(Ligne, Col_ResultatCorrige).Value
Resultat = Cells(Ligne, Col_Resultat).Value
Minimum = Cells(Ligne, Col_Minimum).Value
Maximum = Cells(Ligne, Col_Maximum).Value
CodeUnite = Cells(Ligne, Col_CodeUnite).Value
'On met ces valeurs dans la feuille correspondante
' On commence à la ligne : 7
Sheets(Nom).Cells(Ligne_desti, Col_NoItem_desti).Value = NoItem
Sheets(Nom).Cells(Ligne_desti, Col_NoCasType_desti).Value = NoCasType
Sheets(Nom).Cells(Ligne_desti, Col_DateMes_desti).Value = Date
Sheets(Nom).Cells(Ligne_desti, Col_CodeMesure_desti).Value = CodeMesure
Sheets(Nom).Cells(Ligne_desti, Col_Poids_desti).Value = Poids
Sheets(Nom).Cells(Ligne_desti, Col_ResultatCorrige_desti).Value = ResultatCorrige
Sheets(Nom).Cells(Ligne_desti, Col_Resultat_desti).Value = Resultat
Sheets(Nom).Cells(Ligne_desti, Col_Minimum_desti).Value = Minimum
Sheets(Nom).Cells(Ligne_desti, Col_Maximum_desti).Value = Maximum
Sheets(Nom).Cells(Ligne_desti, Col_CodeUnite_desti).Value = CodeUnite
'On Incrémente la ligne de destination
Ligne_desti = Ligne_desti + 1
End If
Next
End Sub |
Partager