Option Explicit
Public WithEvents boutons As MSForms.CommandButton
Dim cls() As New UserForm1
Public multi As Object
Public pg As Object
Private Sub boutons_Click(): App_button_change boutons.Tag: End Sub
Private Sub UserForm_Activate()
Dim i&, x&, p As Object, bout As Object, b&, bb&, t&, L&
For i = 1 To Feuil1.Cells(Rows.Count, 1).End(xlUp).Row
If Feuil1.Cells(i, 1) = "salle" Then
t = 10: L = 10: bb = 0
Set p = MultiPage1.Pages.Add: x = x + 1: p.Caption = Feuil1.Cells(i + 1, 1)
Else
b = b + 1: bb = bb + 1
Set bout = Me.MultiPage1.Pages(x).Controls.Add("Forms.CommandButton.1", "bt" & x, 1)
bout.Caption = Feuil1.Cells(i, 3): bout.Tag = i
With bout: .Top = t: .Left = L: L = L + 60: .Width = 40
If bb Mod 6 = 0 Then L = 10: t = t + 30
End With
ReDim Preserve cls(1 To b):
With cls(b): Set .boutons = bout: Set .multi = Me.MultiPage1: Set .pg = p: End With
End If
Next
End Sub