D
damien
Guest
bonjour à tous
je voudrai une recherche automatique du style je remplie le combobox2 avec A par exemple et il me liste dans ma listbox tous les navires commencant par A.
merci voici la macro
Private Sub ComboBox2_change()
ListBox1.Clear
ListBox1.IntegralHeight = True
ListBox1.Visible = True
Dim c As Range
Dim x, a As Long
ListBox1.ColumnCount = 9
ListBox1.ColumnWidths = '70;150;50;80;110;50;150;100;0'
x = 0
For Each Row In Worksheets('liste').UsedRange.Rows
If Row.Cells(2) = ComboBox2 Then
a = Row.Row
ListBox1.AddItem Row.Cells(1).Text
ListBox1.List(x, 0) = Row.Cells(1).Text 'immat
ListBox1.List(x, 1) = Row.Cells(2).Text 'nom
ListBox1.List(x, 2) = Row.Cells(3).Text 'lht
ListBox1.List(x, 3) = Row.Cells(5).Text 'port d'attache
ListBox1.List(x, 4) = Row.Cells(6).Text 'pavillon
ListBox1.List(x, 5) = Row.Cells(7).Text ' callsign
ListBox1.List(x, 6) = Row.Cells(8).Text 'type
ListBox1.List(x, 7) = Row.Cells(10).Text
ListBox1.List(x, 8) = a
x = x + 1
End If
Next Row
End Sub
je voudrai une recherche automatique du style je remplie le combobox2 avec A par exemple et il me liste dans ma listbox tous les navires commencant par A.
merci voici la macro
Private Sub ComboBox2_change()
ListBox1.Clear
ListBox1.IntegralHeight = True
ListBox1.Visible = True
Dim c As Range
Dim x, a As Long
ListBox1.ColumnCount = 9
ListBox1.ColumnWidths = '70;150;50;80;110;50;150;100;0'
x = 0
For Each Row In Worksheets('liste').UsedRange.Rows
If Row.Cells(2) = ComboBox2 Then
a = Row.Row
ListBox1.AddItem Row.Cells(1).Text
ListBox1.List(x, 0) = Row.Cells(1).Text 'immat
ListBox1.List(x, 1) = Row.Cells(2).Text 'nom
ListBox1.List(x, 2) = Row.Cells(3).Text 'lht
ListBox1.List(x, 3) = Row.Cells(5).Text 'port d'attache
ListBox1.List(x, 4) = Row.Cells(6).Text 'pavillon
ListBox1.List(x, 5) = Row.Cells(7).Text ' callsign
ListBox1.List(x, 6) = Row.Cells(8).Text 'type
ListBox1.List(x, 7) = Row.Cells(10).Text
ListBox1.List(x, 8) = a
x = x + 1
End If
Next Row
End Sub