Bonjour à tous
tout d'abord un grand merci à vous pour vos contributions.
Je débute en VBA et les nombreux codes présents sur le site m'ont beaucoup aidé.
je rencontre encore deux obstacles dans un code que j'ai "emprunté".
Je voudrais que le troisième colonnes de ma listbox soit au format hh:mm et pas 41450.5555.
ensuite quand le filtre n'a pas de résultat, je voudrais qu'un msgbox s'affiche, que mon combobox soit remis à zero plutôt qu'un plantage.
Merci pour votre aide
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 Private Sub combobox3_change() Dim MonDico As Object Dim c As Range Dim L As Long Dim i As Byte, k As Byte, Nbc As Byte Application.ScreenUpdating = False Nbc = 10 With ListBox1 .Visible = True .ColumnCount = Nbc .ColumnHeads = False .ColumnWidths = "55;65;35;58;55;35;300;40;30" .AddItem Range("a1").Text .Clear End With Set MonDico = CreateObject("Scripting.Dictionary") With Sheets("or_sup") .AutoFilterMode = False L = .Cells(.Rows.Count, "E").End(xlUp).Row .Range("A1:O" & L).AutoFilter Field:=5, Criteria1:=ComboBox3 .Range("A1:O" & L).AutoFilter Field:=8, Criteria1:="" 'If .Range("E2:E" & L).Count = 0 Then ' result = MsgBox("la machine n'est pas DOWN", vbExclamation) ' ComboBox3.Clear If .Range("E2:E" & L).SpecialCells(xlCellTypeVisible).Count > 1 Then For Each c In .Range("A5:A" & L).SpecialCells(xlCellTypeVisible) If Not MonDico.Exists(c.Value) Then MonDico.Add c.Value, c.Value ListBox1.AddItem For k = 0 To Nbc - 1 ListBox1.List(ListBox1.ListCount - 1, k) = c.Offset(0, k) Next k End If Next c End If .AutoFilterMode = False End With Set MonDico = Nothing End Sub
Ben
Partager