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
| Private Sub B_valider_Click()
If Me.LigneEnregC <> 0 And Me.TextBox14 <> "" And LigneEnreg <> 0 Then
lig = LigneEnreg
For Each K In Array(1, 2, 5)
tmp = Me("textbox" & K + 13)
If IsNumeric(tmp) Then
f.Cells(lig, K) = CDbl(tmp)
Else
If IsDate(f.Cells(lig, K)) Then
f.Cells(lig, K) = CDate(tmp)
Else
f.Cells(lig, K) = tmp
End If
End If
Next
f.Cells(lig, 2) = CDate(TextBox15.Value)
f.Cells(lig, 3) = Me.ComboBox3 'employe
If OptionButton1 = True Then
f.Cells(lig, 4) = "Puce1" 'unit
End If
If OptionButton2 = True Then
f.Cells(lig, 4) = "Puce2" 'unit
End If
'f.Cells(lig, 6) = Me.ComboVille 'produit
'f.Cells(lig, 14) = Me.TextBox27 'unit
'f.Cells(lig, 5) = Me.Combocf 'client f
'f.Cells(lig, 2) = Me.Comboaction 'action
Ligne = ListBox1.ListIndex
bv = f.Range("A3:f" & [A65000].End(xlUp).Row).Value
ComboBox1_Change
Me.ListBox1.ListIndex = Ligne
razChampForm
End If
End Sub
Private Sub ListBox1_Click()
Ligne = ListBox1.ListIndex
For Each i In Array(1, 2, 4, 5)
Me("textbox" & i + 13) = ListBox1.List(Ligne, i - 1)
Next i
Me.ggg = ListBox1.List(Ligne, 2) 'categorie
reservation = Me.TextBox14
Set result = f.[A:A].Find(what:=reservation)
If Not result Is Nothing Then
LigneEnreg = result.Row
Me.LigneEnregC = LigneEnreg
Else
MsgBox "Erreur no réservation"
End If
End Sub
Private Sub ComboBox2_Change()
ComboBox1_Change
End Sub
Private Sub UserForm_Initialize()
TextBox15 = Date
Sheets("BDA").Activate
Feuil1.Visible = xlSheetVisible
Set f = Sheets("BDA")
If f.[B3] = "" Then Exit Sub
bv = f.Range("a3:f" & [A65000].End(xlUp).Row).Value
Me.ComboBox3.List = Array("Tom", "Mani", "Ramv")
For i = 1 To UBound(bv, 2) - 1
temp = temp & f.Columns(i).Width * 0.62 & ";"
Me("label" & i) = f.Cells(2, i)
Me("label" & i + 19) = f.Cells(2, i)
Me("label" & i).Top = Me.ListBox1.Top - 15
Largeur = Largeur + f.Columns(i).Width * 1
Next
Me.ListBox1.ColumnWidths = temp: Me.Width = Largeur - 128
Me.ListBox1.List = bv
'--
Set d1 = CreateObject("scripting.dictionary")
For i = 1 To UBound(bv)
If bv(i, 3) <> "" Then d1(bv(i, 3)) = ""
Next i
Cbx1 = d1.Keys
Call tri(Cbx1, LBound(Cbx1), UBound(Cbx1))
Me.ComboBox1.List = Cbx1
Me.ComboBox1.SetFocus
'--
Set d1 = CreateObject("scripting.dictionary")
For i = 1 To UBound(bv)
If bv(i, 2) <> "" Then d1(bv(i, 2)) = CDate(bv(i, 2))
Next i
Cbx2 = d1.items
Call tri(Cbx2, LBound(Cbx2), UBound(Cbx2))
Me.ComboBox2.List = Cbx2
End Sub
Private Sub ComboBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Me.ComboBox1.List = Cbx1
Me.ComboBox1.DropDown
End Sub
Sub razChampForm()
For Each K In Array(1, 2, 4, 5)
Me("textbox" & K + 13) = ""
Next
Me.ggg = ""
End Sub
Sub tri(a, gauc, droi) ' Quick sort
End Sub
Private Sub B_suppression_Click()
If MsgBox("Etes vous sûr?", vbYesNo) = vbYes Then
If LigneEnreg <> 0 Then
Rows(LigneEnreg).Delete
bv = f.Range("a3:f" & [A65000].End(xlUp).Row).Value
ComboBox1_Change
razChampForm
End If
End If
End Sub |