如何为多个button分配一个通用程序?

前段时间我有一个示例代码来为多个button分配相同的过程。
像这样的东西:

For Eeach buttton in Form1 If button is clicked MsgBox button.Caption. 

但是我现在找不到这个代码。
谷歌search我不能find我需要的egcinctly。
我只记得我需要插入一个类模块。
有人能给我一个链接或一个简短的例子。

插入一个新的类模块,并将其命名为clListener (刚才出现在我的脑海里)。
代码在那里:

 Public WithEvents ct As MSForms.CommandButton Public Sub ct_Click() MsgBox ct.Name & " clicked!" End Sub 

在用户窗体模块中:

 Private listenerCollection As New Collection Private Sub UserForm_Initialize() Dim ctItem Dim listener As clListener For Each ctItem In Me.Controls If TypeName(ctItem) = "CommandButton" Then Set listener = New clListener Set listener.ct = ctItem listenerCollection.Add listener End If Next End Sub