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 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265
|
Private Sub OptionButton4_Change()
'Effacement de la liste du ListBox et des sélections + focus auteur sur ""
For x = 0 To ListBox1.ColumnCount
For I = 0 To ListBox1.ListCount - 1
ListBox1.List(I, x) = Clear
Me.ListBox1.Selected(I) = False
Next I
Next x
Application.DisplayAlerts = False 'Utilité à tester ???!!!!
End Sub
Private Sub OptionButton5_Click()
'Effacement de la liste du ListBox et des sélections + focus auteur sur ""
For x = 0 To ListBox1.ColumnCount
For I = 0 To ListBox1.ListCount - 1
ListBox1.List(I, x) = Clear
Me.ListBox1.Selected(I) = False
Next I
Next x
ComboBox1.ListIndex = -1
Application.DisplayAlerts = False 'Utilité à tester ???!!!!
End Sub
Private Sub OptionButton6_Click()
'Effacement de la liste du ListBox et des sélections + focus auteur sur ""
For x = 0 To ListBox1.ColumnCount
For I = 0 To ListBox1.ListCount - 1
ListBox1.List(I, x) = Clear
Me.ListBox1.Selected(I) = False
Next I
Next x
ComboBox1.ListIndex = -1
Application.DisplayAlerts = False 'Utilité à tester ???!!!!
End Sub
Private Sub UserForm_Initialize()
Me.ComboBox1.List = SansDoublonsTrié([REGLEMENTauteur])
Me.ComboBox1.ListIndex = -1 'focus sur auteur = ""
End Sub
Private Sub CommandButton1_Click() 'Bouton RAZ
'Effacement de la liste du ListBox et des sélections + focus auteur sur ""
For x = 0 To ListBox1.ColumnCount
For I = 0 To ListBox1.ListCount - 1
ListBox1.List(I, x) = Clear
Me.ListBox1.Selected(I) = False
Next I
Next x
ComboBox1.ListIndex = -1
Application.DisplayAlerts = False 'Utilité à tester ???!!!!
End Sub
Private Sub CommandButton2_Click() 'Bouton EXIT
'Effacement liste & selections ListBox + focus auteur sur "" + Masquage Userform
For x = 0 To ListBox1.ColumnCount
For I = 0 To ListBox1.ListCount - 1
ListBox1.List(I, x) = Clear
Me.ListBox1.Selected(I) = False
Next I
Next x
ComboBox1.ListIndex = -1
Unload UserForm1
End Sub
Private Sub ComboBox1_click() 'CHARGEMENT AUTEUR
'Effacement de la liste du ListBox et des sélections antérieures + focus auteur sur ""
For x = 0 To ListBox1.ColumnCount
For I = 0 To ListBox1.ListCount - 1
ListBox1.List(I, x) = Clear
Me.ListBox1.Selected(I) = False
Next I
Next x
'ALIMENTATION CONDITIONNELLE DE LISTBOX1
n = 0 'n = ligne textbox
For Each c In Application.Index([REGLEMENTauteur], , 1) 'c = index combobox1
'pour tous les index de la combobox alimentée par la liste REGLEMENTclient
If c.Offset(0, 0) = Me.ComboBox1 Then
' si AUTEUR de la ListBox1 = AUTEUR de la ComboBox1 alors
If OptionButton4.Value = True Then
If c.Offset(0, 11) + c.Offset(0, 21) <> 0 Then
Me.ListBox1.AddItem
Me.ListBox1.List(n, 0) = c.Offset(0, 1) 'Client
Me.ListBox1.List(n, 1) = c.Offset(0, 2) 'date
Me.ListBox1.List(n, 2) = c.Offset(0, 12) 'facture CRI & auteur
Me.ListBox1.List(n, 3) = c.Offset(0, 6) 'TTC Client
Me.ListBox1.List(n, 4) = c.Offset(0, 16) 'TTC Auteur
Me.ListBox1.List(n, 5) = c.Offset(0, 11) - c.Offset(0, 21) 'Solde état
n = n + 1 'n +1 = ligne suivante du textbox
End If 'Fin if optionbutton
End If 'Fin if offset(0,21)
If OptionButton5.Value = True Then
If c.Offset(0, 11) + c.Offset(0, 21) = 0 Then
Me.ListBox1.AddItem
Me.ListBox1.List(n, 0) = c.Offset(0, 1)
Me.ListBox1.List(n, 1) = c.Offset(0, 2)
Me.ListBox1.List(n, 2) = c.Offset(0, 12)
Me.ListBox1.List(n, 3) = c.Offset(0, 6)
Me.ListBox1.List(n, 4) = c.Offset(0, 16)
Me.ListBox1.List(n, 5) = c.Offset(0, 21)
n = n + 1
End If 'Fin if optionbutton
End If 'Fin if offset(0,21)
If OptionButton6.Value = True Then
Me.ListBox1.AddItem
Me.ListBox1.List(n, 0) = c.Offset(0, 1)
Me.ListBox1.List(n, 1) = c.Offset(0, 2)
Me.ListBox1.List(n, 2) = c.Offset(0, 12)
Me.ListBox1.List(n, 3) = c.Offset(0, 6)
Me.ListBox1.List(n, 4) = c.Offset(0, 16)
Me.ListBox1.List(n, 5) = c.Offset(0, 21)
n = n + 1
End If 'Fin if optionbutton
End If 'Fin de la condition "client" en rapport avec "auteur"
Next c 'Index combobox suivant
End Sub
Private Sub CommandButton10_Click() 'TRI FACTURE
'ActiveSheet.Range("A:W").AutoFilter Field:=1, Criteria1:=Me.ComboBox1 'filtrage de l'AUTEUR
'Application.DisplayAlerts = False
'19/02/2009 de ucfoutu à AD via le forum des développeurs
If vbaselcount = 0 Then Exit Sub
Dim I As Integer
Dim montableau() As String 'On ne précise pas la Dimension du tableau, juste String
ReDim montableau(vbaselcount - 1) 'redimensionnement = nb de sélections (via la function vbaselCount)
'redim sans remettre à String sinon => erreur
'vbaselcount-1 car comptage à partir de 0
'ex : Dim Tableau(3) As Integer, déclare un tableau de 4 entiers
n = 0 '1er argument du tableau
For I = 0 To ListBox1.ListCount - 1 'liste toutes les ref de la listBox
If ListBox1.Selected(I) Then 'Trouve les sélections dans la LisBox
montableau(n) = ListBox1.List(I, 2) 'Rempli montableau avec les selections trouvées
'tableau(0) => 1er argument tableau(1)=> 2ème, etc...
n = n + 1 'passe le focus sur l'argument suivant du tableau
End If 'fin de la condition "si sélection dans la ListBox"
Next 'passe à l'élément suivant de la LisBox
ActiveSheet.Range("A:W").AutoFilter Field:=13, Criteria1:=Array(montableau), Operator:=xlFilterValues
' ' et maintenant, juste pour voir ce qu'on a fait
' For I = 0 To UBound(montableau) 'Ubound Retourne le plus grand indice disponible
' 'pour la dimension indiquée d'un tableau
' MsgBox montableau(I)
' Next
'
'Effacement liste & selections ListBox + focus auteur sur "" + Masquage Userform
For x = 0 To ListBox1.ColumnCount
For I = 0 To ListBox1.ListCount - 1
ListBox1.List(I, x) = Clear
Me.ListBox1.Selected(I) = False
Next I
Next x
ComboBox1.ListIndex = -1
'UserForm1.Hide
Unload UserForm1
End Sub
Private Sub CommandButton11_Click() 'TRI CLIENT
ActiveSheet.Range("A:W").AutoFilter Field:=1, Criteria1:=Me.ComboBox1
If vbaselcount = 0 Then
For y = 0 To ListBox1.ColumnCount
For j = 0 To ListBox1.ListCount - 1
ListBox1.List(j, y) = Clear
Me.ListBox1.Selected(j) = False
Next j
Next y
ComboBox1.ListIndex = -1
Unload UserForm1
MsgBox ("sans sélection d'une seule ligne client le TRI s'effectue sur l'AUTEUR avec SOLDES TOUS")
Exit Sub
End If 'si pas de sélections
Dim I As Integer
Dim montableau() As String
ReDim montableau(vbaselcount - 1)
n = 0
For I = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(I) Then
montableau(n) = ListBox1.List(I)
n = n + 1
End If 'su selection(s)
Next
ActiveSheet.Range("A:W").AutoFilter Field:=2, Criteria1:=Array(montableau), Operator:=xlFilterValues
'Effacement liste & selections ListBox + focus auteur sur "" + Masquage Userform
For x = 0 To ListBox1.ColumnCount
For I = 0 To ListBox1.ListCount - 1
ListBox1.List(I, x) = Clear
Me.ListBox1.Selected(I) = False
Next I
Next x
ComboBox1.ListIndex = -1
Unload UserForm1 'Userform1.Hide
End Sub
Private Sub CommandButton12_Click() 'TRI AUTEUR
ActiveSheet.Range("A:W").AutoFilter Field:=1, Criteria1:=Me.ComboBox1 'filtrage de l'AUTEUR
'Application.DisplayAlerts = False
If vbaselcount = 0 Then
End If
For y = 0 To ListBox1.ColumnCount
For j = 0 To ListBox1.ListCount - 1
ListBox1.List(j, y) = Clear
Me.ListBox1.Selected(j) = False
Next j
Next y
ComboBox1.ListIndex = -1
Unload UserForm1 'Userform1.Hide
End Sub
Private Function vbaselcount() As Integer
For I = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(I) Then
vbaselcount = vbaselcount + 1
End If
Next
End Function |
Partager