tri combobox à partir de feuilles sous condition

Neptune

XLDnaute Junior
Bonjour,

J'ai une comboBox qui me donne toutes mes feuilles ayant la donnée:VALEUR dans une cellule spécifique de la feuille.

Private Sub UserForm_Initialize()

ComboBox1.Clear

For Each X In Sheets
If X.Cells(1, 8).Value = "VERSION" Then
ComboBox1.AddItem X.Name
End If
Next X


Je voudrais le modifier avec ce programme qui fait appel au tri d'une combobox (Quick Sort):

Private Sub UserForm_Initialize()
Dim temp()
temp = Range("liste") ' liste tableau temp (1 To n,1 To 1) ou temp = Range([B2], [B2].End(xlDown))
Call tri(temp, 1, UBound(temp, 1))
Me.ListBox1.List = temp
End Sub



Comment remplacer le range("liste") par mon ComboBox1?

temp=ComboBox....

Merci
 

BOISGONTIER

XLDnaute Barbatruc
Repose en paix
Re : tri combobox à partir de feuilles sous condition

Bonsoir,

Code:
Private Sub UserForm_Initialize()
  Dim temp()
  k = 1
  For Each sh In ActiveWorkbook.Sheets
   If sh.Cells(1, 8) = "VERSION" Then
     ReDim Preserve temp(1 To k)
     temp(k) = sh.Name
     k = k + 1
    End If
  Next sh
  Call Tri(temp, LBound(temp), UBound(temp))
  Me.ComboBox1.List = temp
  Me.ComboBox1.ListIndex = 0
End Sub

Sub Tri(a, gauc, droi)          ' Quick sort
 ref = a((gauc + droi) \ 2)
 g = gauc: d = droi
 Do
     Do While a(g) < ref: g = g + 1: Loop
     Do While ref < a(d): d = d - 1: Loop
     If g <= d Then
       temp = a(g): a(g) = a(d): a(d) = temp
       g = g + 1: d = d - 1
     End If
 Loop While g <= d
 If g < droi Then Call Tri(a, g, droi)
 If gauc < d Then Call Tri(a, gauc, d)
End Sub

JB
Formation Excel VBA JB
 

Discussions similaires

Statistiques des forums

Discussions
312 490
Messages
2 088 875
Membres
103 980
dernier inscrit
grandmasterflash38