Private Sub UserForm_Activate()
    Dim plage As Range, C&, Cw$
    Set plage = [A1:G10]
    With ListBox1
        .List = plage.Value
        .ColumnCount = plage.Columns.Count
        For C = 1 To plage.Columns.Count
            Cw = Cw & plage.Cells(1, C).Width & IIf(C < plage.Columns.Count, ";", "")
        Next
        .ColumnWidths = Cw
    End With
End Sub
Private Sub ListBox1_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    Dim tbl, x1&
    If Button = 2 Then createmenu
End Sub
Public Function createmenu()
    AddMacro "Feuil1", "UptoListe", _
            "Public Sub UpToListe", _
            "      " & Me.Name & ".UptoListe", _
            "End Sub"
    On Error Resume Next
    CommandBars("menulist").Delete
    Err.Clear
    Set Barre = CommandBars.Add("Menulist", msoBarPopup, False, True)
    Set bout = Barre.Controls.Add(msoControlButton, 1, , , True)
    bout.Caption = "envoyer en haut de liste"
    bout.OnAction = "Feuil1.UpToListe"     'not working
    'etc...
    'etc....
    Barre.ShowPopup
    On Error Resume Next
    CommandBars("menulist").Delete
    Err.Clear
 
End Function
Public Sub UpToListe()
    MsgBox "coucou"
End Sub
Sub AddMacro(Target As String, MacroName As String, ParamArray Line())
    With ActiveWorkbook.VBProject.VBComponents(Target).CodeModule
     On Error Resume Next
     X = .ProcStartLine(MacroName, 0)
     If Err > 0 Then .InsertLines .CountOfLines + 1, Join(Line, vbLf)
    End With
End Sub
Sub DelMacro(Target As String, MacroName As String)
    Dim Start As Integer, NLignes As Integer
    
    With ActiveWorkbook.VBProject.VBComponents(Target).CodeModule
        Start = .ProcStartLine(MacroName, 0)
        NLignes = .ProcCountLines(MacroName, 0)
        .DeleteLines Start, NLignes
    End With
End Sub
Private Sub UserForm_Terminate()
    DelMacro "Feuil1", "UptoListe"
End Sub