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
| 'Bouton <Ok>'
Private Sub CommandButton1_Click()
Dim lastCol As Integer
lastCol = Range("B1").End(xlToRight).Column
Application.ScreenUpdating = False
Range(Cells(1, 2), Cells(1, lastCol)).EntireColumn.Hidden = True
Columns(ComboBox1.ListIndex + 2).EntireColumn.Hidden = False
UserForm1.Hide
Application.ScreenUpdating = True
End Sub
'Affichage du UserForm
Private Sub UserForm_Activate()
Dim lastCol As Integer
Application.ScreenUpdating = False
Range(Cells(1, 2), Cells(1, Columns.Count)).EntireColumn.Hidden = False
lastCol = Range("B1").End(xlToRight).Column
Dim vals As Variant
vals = Range(Cells(1, 2), Cells(1, lastCol))
ComboBox1.Clear
Dim vali As Integer
For vali = 1 To UBound(vals, 2)
Call ComboBox1.AddItem(vals(1, vali))
Next vali
ComboBox1.Text = vals(1, 1)
Application.ScreenUpdating = True
End Sub |
Partager