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
| Public Sub Nom_TRAV_ComboBox_Change()
Dim k%, derl%, cnomTRAV%, cnomTUY%, Ccouloir%, Catelier%, l%, i%
derl = NombreDeLignes("Inventaire_TUY_TRAV")
cnomTRAV = ChercheColonne("Inventaire_TUY_TRAV", "Nom TRAV")
cnomTUY = ChercheColonne("Inventaire_TUY_TRAV", "Nom TUY")
Ccouloir = ChercheColonne("Inventaire_TUY_TRAV", "Capsage TUY Couloir")
Catelier = ChercheColonne("Inventaire_TUY_TRAV", "Capsage TUY Atelier")
l = 0
With Rempl_Inv_TUY_TRAV
.TUY_TRAV_ListBox.Clear
For k = 2 To derl
If Worksheets("Inventaire_TUY_TRAV").Cells(k, cnomTRAV) = .Nom_TRAV_ComboBox Then
'Je créé un tableau dynamique dans lequel je range mes numéros de lignes
ReDim Tabligne(i)
Tabligne(i) = k
i = i + 1
With .TUY_TRAV_ListBox
.ColumnCount = 3
.AddItem
.List(l, 0) = Worksheets("Inventaire_TUY_TRAV").Cells(k, Ccouloir).Value
.List(l, 1) = Worksheets("Inventaire_TUY_TRAV").Cells(k, cnomTUY).Value
.List(l, 2) = Worksheets("Inventaire_TUY_TRAV").Cells(k, Catelier).Value
l = l + 1
End With
End If
Next
End With
Public Sub Enregistrer_TRAV_CommandButton_Click()
Dim kmax%, k%, derl%, Cdat%, cnomTRAV%, czi%, cnomTUY%, Ccouloir%, Catelier%, i%, j%
kmax = Rempl_Inv_TUY_TRAV.TUY_TRAV_ListBox.ListCount
derl = NombreDeLignes("Inventaire_TUY_TRAV") + 1
Cdat = ChercheColonne("Inventaire_TUY_TRAV", "Date Inventaire")
cnomTRAV = ChercheColonne("Inventaire_TUY_TRAV", "Nom TRAV")
czi = ChercheColonne("Inventaire_TUY_TRAV", "ZI")
cnomTUY = ChercheColonne("Inventaire_TUY_TRAV", "Nom TUY")
Ccouloir = ChercheColonne("Inventaire_TUY_TRAV", "Capsage TUY Couloir")
Catelier = ChercheColonne("Inventaire_TUY_TRAV", "Capsage TUY Atelier")
With Worksheets("Inventaire_TUY_TRAV")
'lorsque je rappel le tableau il se trouve vide
For i = 0 To UBound(Tabligne)
j = Tabligne(i)
.Cells(j, 1).EntireRow.Delete
Next i
If kmax <> 0 Then
For k = 0 To kmax - 1
.Cells(derl + k, czi) = Rempl_Inv_TUY_TRAV.ZI_TUY_TRAV_ComboBox
.Cells(derl + k, cnomTRAV) = Rempl_Inv_TUY_TRAV.Nom_TRAV_ComboBox
.Cells(derl + k, Ccouloir) = Rempl_Inv_TUY_TRAV.TUY_TRAV_ListBox.List(k, 0)
.Cells(derl + k, cnomTUY) = Rempl_Inv_TUY_TRAV.TUY_TRAV_ListBox.List(k, 1)
.Cells(derl + k, Catelier) = Rempl_Inv_TUY_TRAV.TUY_TRAV_ListBox.List(k, 2)
.Cells(derl + k, Cdat) = Now
Next
End If
End With
Unload Rempl_Inv_TUY_TRAV
End Sub |