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
| Function nb_ligne_article()
'compter le nb de ligne feuille articles
nb_ligne_article = Sheets("articles").Range("A1").End(xlDown).Row
Sheets("Interface").Range("F2").Value = nb_ligne_article
'trier la liste des articles
Sheets("articles").Activate
'blablabla
'- - - - - - - - - - - - - - - - - - - -
'isoler la liste des catégories unique
'- - - - - - - - - - - - - - - - - - - -
'nettoyerla liste des catégories
Sheets("BdD").Range("A:A").Clear
'mettre à jour la liste des catégories
With Sheets("articles")
Dim cpt_categorie As Integer
cpt_categorie = 1
For i = 2 To nb_ligne_article
Sheets("BdD").Range("A" & cpt_categorie).Value = Range("B" & i).Value
With Sheets("articles")
If Range("B" & i).Value = Range("B" & i + 1).Value Then
cpt_categorie = cpt_categorie
Else
cpt_categorie = cpt_categorie + 1
End If
End With
Next i
End With
'creer la liste de catégorie pour alimenter la cellule /menu déroulant
Sheets("BdD").Activate
Range("A1:A" & cpt_categorie).Select
ActiveWorkbook.Names.Add Name:="Categorie", RefersTo:=Selection
With Sheets("Interface").Select
Range("B15:D15").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=Categorie"
' blalblabla
End With
End With
'récupération de la valeur de Interface!B15
Dim choix_categorie As String
choix_categorie = Range("B15").Value
Range("G2").Value = choix_categorie
'- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
'isoler les familles possibles en fonction du choix catégorie
'- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
'definir le nombre d'élémenst dans la catégorie choisie
Dim famille As String
Dim L1_famille As Integer
Dim Lx_famille As Integer
Dim nb_cat_choix As Integer
With Sheets("Articles").Activate
'trouver la premiere ligne dans la catégorie choisie
L1_famille = Range("B:B").Find(choix_categorie, lookat:=xlWhole).Row
'compter le nb de famille dans la catégorie choisie
nb_cat_choix = Application.WorksheetFunction.CountIf( _
Range("B:B"), choix_categorie)
'trouver la derniere ligne dans la catégorie choisie
Lx_famille = (L1_famille + nb_cat_choix) - 1
'créer la liste des familles unique en fonction du choix categorie
Sheets("BdD").Range("B:B").Clear
Dim cpt_famille As Integer
cpt_famille = 1
For i = L1_famille To Lx_famille
Sheets("BdD").Range("B" & cpt_famille).Value = Range("D" & i).Value
With Sheets("articles")
If Range("D" & i).Value = Range("D" & i + 1).Value Then
cpt_famille = cpt_famille
Else
cpt_famille = cpt_famille + 1
End If
End With
Next i
'creer la liste de famille pour alimenter la cellule /menu déroulant
Sheets("BdD").Activate
Range("B1:B" & (cpt_famille - 1)).Select
ActiveWorkbook.Names.Add Name:="Famille", RefersTo:=Selection
With Sheets("Interface").Select
Range("B17").Clear
Range("B17").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=Famille"
'blablabla
End With
End With
End With
End Function |
Partager