Pour le point 1
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Target, Range("B2")) Is Nothing Then Exit Sub
Target.Validation.Delete
Target.Validation.Add xlValidateList, Formula1:=Join(choix("MesMacros"), ",")
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("B2")) Is Nothing Then Exit Sub
Set ici = Target
If ici.Value <> "" Then onyva (ici.Value)
ici.Offset(1, 0).Select
End Sub
Dim dico As Object
Function choix(NomDuModule As String) As Variant()
'Nécéssite d'activer la référence "Microsoft Visual basic For Application Extensibility 5.3"
Dim temp()
Set dico = CreateObject("Scripting.Dictionary")
n = 0
For n = 1 To ActiveWorkbook.VBProject.VBComponents.Count
With ActiveWorkbook.VBProject.VBComponents(n).CodeModule
If .Name = NomDuModule Then
For i = 1 To .CountOfLines
If .Lines(i, 1) Like "Sub*" Then
n = n + 1
ReDim Preserve temp(n)
temp(n) = Replace(.Lines(i + 1, 1), "'", "")
dico(temp(n)) = Replace(Replace(.Lines(i, 1), "Sub ", ""), "()", "")
End If
Next
End If
End With
Next
choix = temp
End Function
Sub onyva(txt As String)
Application.Run dico(txt)
End Sub
Contenu du module MesMacros, pas d'espace entre l'apostroph et le commentaire repris dans le menu déroulant.
Sub test1()
'Hello !
MsgBox "macro test1 exécutée avec succès !"
End Sub
Sub test2()
'Vous êtes ici ...
MsgBox "macro test2 exécutée avec succès !"
End Sub
Sub test3()
'En avant !
MsgBox "macro test3 exécutée avec succès !"
End Sub
je vais voir pour créer le userform (beurk !)