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 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
| Private Sub CmdAjouter_Click()
ligne = Sheets("base").[A65000].End(xlUp).Row + 1
Me.ComboBox_nom = ""
Me.TextBox_pro = ""
Me.CheckBox_Achat = False
Me.ComboBox_annee = ""
Me.ComboBox_mois = ""
Me.TextBox_CA = ""
Me.ComboBox_connais = ""
Me.ComboBox_parrainage = ""
Me.ComboBox_ville = ""
Me.ComboBox_FAI = ""
Me.ComboBox_antivirus = ""
End Sub
Private Sub CmdAnnuler_Click()
Unload Me
End Sub
Private Sub CmdValider_Click()
Sheets("Base").Cells(ligne, 2) = Application.Proper(Me!ComboBox_nom)
Sheets("Base").Cells(ligne, 3) = Application.Proper(Me.TextBox_pro)
Sheets("Base").Cells(ligne, 4) = Me.CheckBox_Achat 'OuiNon(Me.Achat)
Sheets("Base").Cells(ligne, 5) = Me.ComboBox_annee
Sheets("Base").Cells(ligne, 6) = Me.ComboBox_mois
Sheets("Base").Cells(ligne, 7) = Me.TextBox_CA
If TextBox_CA.Text = "" Then
MsgBox "Le C.A. n'est pas indiqué"
Exit Sub
End If
Sheets("Base").Cells(ligne, 8) = Application.Proper(Me.ComboBox_connais)
Sheets("Base").Cells(ligne, 9) = Me.ComboBox_parrainage
Sheets("Base").Cells(ligne, 10) = Application.Proper(Me.ComboBox_ville)
Sheets("Base").Cells(ligne, 11) = Application.Proper(Me.ComboBox_FAI)
Sheets("Base").Cells(ligne, 12) = Application.Proper(Me.ComboBox_antivirus)
End Sub
Private Sub ComboBox_nom_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If IsError(Application.Match(Me.ComboBox_nom, Range("Listes_clients"), 0)) And Me.ComboBox_nom <> "" Then
If MsgBox("Etes vous sûr?", vbYesNo) = vbYes Then
Range("Listes_clients").End(xlDown).Offset(1, 0) = Me.ComboBox_nom
Range("Listes_clients").Sort Key1:=Range("Listes_clients")(1)
End If
End If
End Sub
Private Sub ComboBox_annee_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If IsError(Application.Match(Me.ComboBox_annee, Range("Listes_annee"), 0)) And Me.ComboBox_annee <> "" Then
If MsgBox("Etes vous sûr?", vbYesNo) = vbYes Then
Range("Listes_annee").End(xlDown).Offset(1, 0) = Me.ComboBox_annee
Range("Listes_annee").Sort Key1:=Range("Listes_annee")(1)
End If
End If
End Sub
Private Sub ComboBox_connais_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If IsError(Application.Match(Me.ComboBox_connais, Range("Listes_connaissances"), 0)) And Me.ComboBox_connais <> "" Then
If MsgBox("Etes vous sûr?", vbYesNo) = vbYes Then
Range("Listes_connaissances").End(xlDown).Offset(1, 0) = Me.ComboBox_connais
Range("Listes_connaissances").Sort Key1:=Range("Listes_connaissances")(1)
End If
End If
End Sub
Private Sub ComboBox_ville_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If IsError(Application.Match(Me.ComboBox_ville, Range("Listes_villes"), 0)) And Me.ComboBox_ville <> "" Then
If MsgBox("Etes vous sûr?", vbYesNo) = vbYes Then
Range("Listes_villes").End(xlDown).Offset(1, 0) = Me.ComboBox_ville
Range("Listes_villes").Sort Key1:=Range("Listes_villes")(1)
End If
End If
End Sub
Private Sub ComboBox_FAI_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If IsError(Application.Match(Me.ComboBox_FAI, Range("Listes_FAI"), 0)) And Me.ComboBox_FAI <> "" Then
If MsgBox("Etes vous sûr?", vbYesNo) = vbYes Then
Range("Listes_FAI").End(xlDown).Offset(1, 0) = Me.ComboBox_FAI
Range("Listes_FAI").Sort Key1:=Range("Listes_FAI")(1)
End If
End If
End Sub
Private Sub ComboBox_antivirus_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If IsError(Application.Match(Me.ComboBox_antivirus, Range("Listes_antivirus"), 0)) And Me.ComboBox_antivirus <> "" Then
If MsgBox("Etes vous sûr?", vbYesNo) = vbYes Then
Range("Listes_antivirus").End(xlDown).Offset(1, 0) = Me.ComboBox_antivirus
Range("Listes_antivirus").Sort Key1:=Range("Listes_antivirus")(1)
End If
End If
End Sub
Private Sub CheckBox_Achat_Click()
'Si casse cocher, la valeur 1 sera renvoyer sur la ligne active dans la colonne D de la feuille Base
If CheckBox_Achat.Value Then
Range("D").Value = 1
Else
Colunms("D").Value = ""
End If
End Sub
Private Sub UserForm_Activate()
If Range("E3").Value Then
Me.CheckBox_Achat.Value = True
Else: Me.CheckBox_Achat.Value = False
End If
End Sub
Private Sub CmdPremier_Click()
ComboBox1.ListIndex = 0
End Sub
Private Sub ComboBox1_Change()
If ComboBox1.ListIndex = -1 Then Exit Sub
Me.CmdPremier.Enabled = True
Me.CmdPrecedent.Enabled = True
Me.CmdSuivant.Enabled = True
Me.CmdDernier.Enabled = True
Select Case ComboBox1.ListIndex
Case -1
Me.CmdPremier.Enabled = False
Case 0
Me.CmdPrecedent.Enabled = False
Me.CmdPremier.Enabled = False
Case ComboBox1.ListCount - 1
Me.CmdSuivant.Enabled = False
Me.CmdDernier.Enabled = False
End Select
Worksheets("Base").Cells(ComboBox1.ListIndex + 1, 1).Select
Navigue ActiveCell.Row
End Sub
Private Sub CmdPrecedent_Click()
ComboBox1.ListIndex = ComboBox1.ListIndex - 1
End Sub
Private Sub CmdSuivant_Click()
ComboBox1.ListIndex = ComboBox1.ListIndex + 1
End Sub
Private Sub CmdDernier_Click()
ComboBox1.ListIndex = ComboBox1.ListCount - 1
End Sub
Private Sub Navigue(L As Long)
Dim i As Byte
With Worksheets("Base")
For i = 2 To 10
Me("TextBox" & i) = .Cells(L, i)
Next
End With
End Sub
Private Sub UserForm_Initialize()
ComboBox_mois.ListIndex = Month(Now()) - 1
ComboBox_annee = Year(Now)
With Worksheets("Base")
Me.ComboBox1.List = .Range("b2:B" & .Range("A65536").End(xlUp).Row).Value
Me.ComboBox1.ListIndex = ActiveCell.Row - 1
End With
'Range(Sheets("Base").[a2], Sheets("Base").[a65000].End(xlUp))
End Sub |
Partager