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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
| Dim f, ColMax, LetCol, Max, Colonne
Private Sub UserForm_initialize()
Dim ComboBD
Set f = Sheets("BDD")
ColMax = f.Cells(1, f.Cells.Columns.Count).End(xlToLeft).Column
LetColMax = Split(f.Cells(1, ColMax).Address, "$")(1) & 1
ComboBD = WorksheetFunction.Transpose(f.Range("B1:" & LetColMax))
Me.ComboBox1.Clear
If ColMax < 2 Then Exit Sub
If ColMax = 2 Then Me.ComboBox1.AddItem f.Range("B1"): Exit Sub
Me.ComboBox1.List = ComboBD
End Sub
Private Sub ComboBox1_Change()
Dim Plage
If Me.ComboBox1 = "" Then Me.ListBox1.Clear: Exit Sub
Me.ListBox1.Clear
Colonne = Me.ComboBox1.ListIndex + 2
LetCol = Split(f.Cells(1, Colonne).Address, "$")(1)
Max = f.Cells(65000, Colonne).End(xlUp).Row
Plage = LetCol & 2 & ":" & LetCol & Max
If Max = 2 Then Me.ListBox1.Clear: Me.ListBox1.AddItem f.Cells(2, Colonne)
If Max > 2 Then ListeBD = f.Range(Plage).Value: Me.ListBox1.List = ListeBD
Me.ListBox1.ColumnWidths = f.Columns(Colonne).Width
End Sub
Private Sub Image2_Click()
Dim MSG
MSG = InputBox("Quel est le tire de la nouvelle liste ?", "Ajout d'une liste")
If MSG = "" Then Exit Sub
f.Cells(1, ColMax + 1) = MSG
f.Columns.AutoFit
UserForm_initialize
Me.ComboBox1 = MSG
End Sub
Private Sub Image3_Click()
Dim MSG
If Me.ComboBox1 = "" Then Exit Sub
MSG = InputBox("Quel est le nouveau titre de la liste ?", "Modification", Me.ComboBox1)
If MSG = "" Then Exit Sub
f.Cells(1, Colonne) = MSG
f.Columns.AutoFit
UserForm_initialize
Me.ComboBox1 = MSG
End Sub
Private Sub Image4_Click()
Dim MSG
If Me.ComboBox1 = "" Then Exit Sub
MSG = MsgBox("Confirmer la suppression de la liste " & Me.ComboBox1 & " ainsi que tout son contenue ?", vbYesNo + vbCritical, "Suppression")
If MSG = vbYes Then
f.Columns(LetCol & ":" & LetCol).Delete shift:=xlToLeft
UserForm_initialize
End If
If MSG = vbNo Then
Exit Sub
End If
End Sub
Private Sub Image5_Click()
Dim MSG
If Me.ComboBox1 = "" Then Exit Sub
MSG = InputBox("Quel est le nouvel item à ajouter ?", "Ajout dans liste " & Me.ComboBox1)
If MSG = "" Then Exit Sub
If IsDate(MSG) Then f.Cells(Max + 1, Colonne) = CDate(MSG)
If Not IsDate(MSG) Then f.Cells(Max + 1, Colonne) = MSG
If Max > 1 Then f.Range(LetCol & 2 & ":" & LetCol & Max + 1).Sort key1:=f.Cells(3, Colonne), order1:=xlAscending
f.Columns(LetCol & ":" & LetCol).AutoFit
ComboBox1_Change
End Sub
Private Sub Image7_Click()
Dim MSG
If Me.ComboBox1 = "" Then Exit Sub
If IsNull(Me.ListBox1) = True Then Exit Sub
MSG = InputBox("Modification de l'item suivant :", "Modification", Me.ListBox1)
If MSG = "" Then Exit Sub
If IsDate(MSG) Then f.Cells(Me.ListBox1.ListIndex + 2, Colonne) = CDate(MSG)
If Not IsDate(MSG) Then f.Cells(Me.ListBox1.ListIndex + 2, Colonne) = MSG
If Max > 1 Then f.Range(LetCol & 2 & ":" & LetCol & Max + 1).Sort key1:=f.Cells(3, Colonne), order1:=xlAscending
f.Columns(LetCol & ":" & LetCol).AutoFit
ComboBox1_Change
End Sub
Private Sub Image6_Click()
Dim MSG
If Me.ComboBox1 = "" Then Exit Sub
If IsNull(Me.ListBox1) = True Then Exit Sub
MSG = MsgBox("Confirmer la supression de " & Me.ListBox1 & " ?", vbYesNo + vbCritical, "Supression")
If MSG = vbYes Then f.Cells(Me.ListBox1.ListIndex + 2, Colonne).Delete shift:=xlUp
If MSG = vbNo Then Exit Sub
f.Columns(LetCol & ":" & LetCol).AutoFit
ComboBox1_Change
End Sub
Private Sub Image1_Click()
Unload Me
End Sub |
Partager