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
| Dim f, ligneEnreg
Private Sub UserForm_Initialize()
ComboBox1.AddItem "Achat"
ComboBox1.AddItem "Autres éléments"
ComboBox1.AddItem "Location"
ComboBox1.AddItem "Matériel"
ComboBox1.AddItem "Personnel"
End Sub
Private Sub ComboBox1_Click()
If ComboBox1.Value = "Achat" Then
Set f = Sheets("Feuille de prix")
Clé = f.Range("E2:E" & f.[E65000].End(xlUp).Row)
'-------------avec tri---------------
Call Tri(Clé, LBound(Clé), UBound(Clé))
Me.ComboBox2.List = Clé
Me.ComboBox2.ListIndex = -1
CommandButton2_Click
ElseIf ComboBox1.Value = "Autres éléments" Then
Clé = f.Range("M2:M" & f.[M65000].End(xlUp).Row)
'-------------avec tri---------------
Call Tri(Clé, LBound(Clé), UBound(Clé))
Me.ComboBox2.List = Clé
Me.ComboBox2.ListIndex = -1
CommandButton2_Click
ElseIf ComboBox1.Value = "Location" Then
Clé = f.Range("T2:T" & f.[T65000].End(xlUp).Row)
'-------------avec tri---------------
Call Tri(Clé, LBound(Clé), UBound(Clé))
Me.ComboBox2.List = Clé
Me.ComboBox2.ListIndex = -1
CommandButton2_Click
ElseIf ComboBox1.Value = "Matériel" Then
Clé = f.Range("AB2:AB" & f.[AB65000].End(xlUp).Row)
'-------------avec tri---------------
Call Tri(Clé, LBound(Clé), UBound(Clé))
Me.ComboBox2.List = Clé
Me.ComboBox2.ListIndex = -1
CommandButton2_Click
ElseIf ComboBox1.Value = "Personnel" Then
Clé = f.Range("AJ2:AJ" & f.[AJ65000].End(xlUp).Row)
'-------------avec tri---------------
Call Tri(Clé, LBound(Clé), UBound(Clé))
Me.ComboBox2.List = Clé
Me.ComboBox2.ListIndex = -1
CommandButton2_Click
End If
End Sub
Private Sub ComboBox2_Click()
If ComboBox1.Value = "Achat" Then
ligneEnreg = Sheets("Feuille de prix").Range("E:K").Find(ComboBox2, LookIn:=xlValues).Row
Me.TextBox1 = f.Cells(ligneEnreg, 6)
Me.TextBox6 = f.Cells(ligneEnreg, 11)
Me.TextBox4 = f.Cells(ligneEnreg, 9)
Me.TextBox3 = f.Cells(ligneEnreg, 7)
Me.TextBox2 = f.Cells(ligneEnreg, 8)
Me.TextBox5 = f.Cells(ligneEnreg, 5)
ElseIf ComboBox1.Value = "Autres éléments" Then
ElseIf ComboBox1.Value = "Location" Then
ElseIf ComboBox1.Value = "Matériel" Then
ElseIf ComboBox1.Value = "Personnel" Then
End If
End Sub
Private Sub CommandButton3_Click()
If Me.TextBox5 = "" Then
MsgBox "Saisir un nom"
Me.TextBox5.SetFocus
Exit Sub
End If
'--- Transfert Formulaire dans BD
f.Cells(ligneEnreg, 6) = Me.TextBox1
f.Cells(ligneEnreg, 8) = Me.TextBox2
f.Cells(ligneEnreg, 7) = Me.TextBox3
f.Cells(ligneEnreg, 9) = Me.TextBox4
f.Cells(ligneEnreg, 11) = Me.TextBox6
f.Cells(ligneEnreg, 5) = Application.Proper(Me!TextBox5)
UserForm_Initialize
End Sub
Private Sub CommandButton2_Click()
ligneEnreg = f.[E65000].End(xlUp).Row + 1
Me.TextBox5 = ""
End Sub
Private Sub CommandButton4_Click()
If MsgBox("Etes vous sûr de suppimer " & f.Cells(ligneEnreg, 2) & "?", vbYesNo) = vbYes Then
ncol = 7
f.Cells(ligneEnreg, 1).Resize(, ncol).Delete Shift:=xlUp
UserForm_Initialize
End If
End Sub
Private Sub b_fin_Click()
Unload Me
End Sub
Sub Tri(a, gauc, droi) ' Quick sort
ref = a((gauc + droi) \ 2, 1)
g = gauc: d = droi
Do
Do While a(g, 1) < ref: g = g + 1: Loop
Do While ref < a(d, 1): d = d - 1: Loop
If g <= d Then
temp = a(g, 1): a(g, 1) = a(d, 1): a(d, 1) = temp
g = g + 1: d = d - 1
End If
Loop While g <= d
If g < droi Then Call Tri(a, g, droi)
If gauc < d Then Call Tri(a, gauc, d)
End Sub |