Private Sub OptionButton1_Click()
With Sheets("Tableau (2)")
Me.TextBox1 = .[D4]
Me.ListBox1.List = .Range("D5:D" & .Range("D65536").End(xlUp).Row).Value
End With
End Sub
Private Sub OptionButton1_Click()
Affiche "Tableau"
End Sub
Private Sub OptionButton2_Click()
Affiche "Tableau (2)"
End Sub
Private Sub OptionButton3_Click()
Affiche "Tableau (3)"
End Sub
Private Sub OptionButton4_Click()
Affiche "Tableau (4)"
End Sub
Sub Affiche(NomFeuille As String)
Dim liste As Range
With Sheets(NomFeuille)
TextBox1 = .[D4]
Set liste = .Range("D5", .[D65536].End(xlUp)) 'liste dynamique
If liste.Row < 5 Then ListBox1.Clear: Exit Sub 'si liste vide
ListBox1.List = liste.Value
End With
End Sub
Private Sub UserForm_Initialize()
For i = 2 To Sheets.Count
Me.ComboBox1.AddItem Sheets(i).Name
Next i
End Sub
Private Sub ComboBox1_Change()
m = Me.ComboBox1
With Sheets(m)
Me.TextBox1 = .[D4]
Me.ListBox1.List = .Range("D5:D" & .Range("D65536").End(xlUp).Row).Value
End With
End Sub
Dim tablo() 'mémorisation
Private Sub ComboBox1_Change()
Dim liste As Range
ListBox1.Clear
If ComboBox1.ListIndex = -1 Then Exit Sub
With Sheets(tablo(1, ComboBox1.ListIndex))
Set liste = .Range("D5", .[D65536].End(xlUp)) 'liste dynamique
End With
If liste.Row = 5 Then ListBox1.List = liste.Value
End Sub
Private Sub UserForm_Initialize()
Dim w As Worksheet, n As Integer
For Each w In Worksheets
If w.Name Like "Tableau*" Then
ReDim Preserve tablo(1, n) 'base 0
tablo(0, n) = w.[D4]
tablo(1, n) = w.Name
n = n + 1
End If
Next
ComboBox1.List = Application.Transpose(tablo)
End Sub
Private Sub ComboBox1_Change()
Dim liste As Range
ListBox1.Clear
If ComboBox1.ListIndex = -1 Then Exit Sub
With Sheets(ComboBox1.Value)
Set liste = .Range("D5", .[D65536].End(xlUp)) 'liste dynamique
End With
If liste.Row = 5 Then ListBox1.List = liste.Value
End Sub
Private Sub UserForm_Initialize()
Dim w As Worksheet, tablo(), n As Integer
For Each w In Worksheets
If w.Name Like "Tableau*" Then
ReDim Preserve tablo(1, n) 'base 0
tablo(0, n) = w.[D4]
tablo(1, n) = w.Name
n = n + 1
End If
Next
ComboBox1.List = Application.Transpose(tablo)
End Sub
Sub tri(a, gauc, droi) ' Quick sort aménagée
Dim ref, g, d, temp
ref = a(0, (gauc + droi) \ 2)
g = gauc: d = droi
Do
Do While a(0, g) < ref: g = g + 1: Loop
Do While ref < a(0, d): d = d - 1: Loop
If g <= d Then
temp = a(0, g): a(0, g) = a(0, d): a(0, d) = temp
temp = a(1, g): a(1, g) = a(1, d): a(1, 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
If n = 1 Then
ComboBox1.AddItem tablo(0, 0)
ComboBox1.List(0, 1) = tablo(1, 0)
ElseIf n Then
Call tri(tablo, 0, n - 1)
ComboBox1.List = Application.Transpose(tablo)
End If
End Sub
Private Sub UserForm_Initialize()
For i = 2 To Sheets.Count
Me.ComboBox1.AddItem Sheets(i).Name
Next i
End Sub
Private Sub ComboBox1_Change()
m = Me.ComboBox1
With Sheets(m)
Me.TextBox1 = .[D4]
Me.ListBox1.List = .Range("D5:D" & .Range("D65536").End(xlUp).Row).Value
End With
End Sub
Private Sub OptionButton1_Click()
Affiche "Tableau"
End Sub
Private Sub OptionButton2_Click()
Affiche "Tableau (2)"
End Sub
Private Sub OptionButton3_Click()
Affiche "Tableau (3)"
End Sub
Private Sub OptionButton4_Click()
Affiche "Tableau (4)"
End Sub
Sub Affiche(NomFeuille As String)
Dim liste As Range
With Sheets(NomFeuille)
TextBox1 = .[D4]
Set liste = .Range("D5", .[D65536].End(xlUp)) 'liste dynamique
If liste.Row < 5 Then ListBox1.Clear: Exit Sub 'si liste vide
ListBox1.List = liste.Value
End With
End Sub