Excel VBA – 将button标题传递给button单击

我目前有一个电子表格,使用下面的方法创build和销毁一些button。 123456表示我想用“VIEW_SO”查找的销售订单

Dim btn As Button Set btn = ws.Buttons.Add(cell.left, cell.top , cell.width, cell.height) With btn .OnAction = "VIEW_SO" .caption = "SO=123456" .name = "SO123456" End With 

这很好。 问题在于我希望VIEW_SO根据销售数量来改变其行为。 有没有办法在程序中获得button名称或标题? 以下是我想要做的:

 Public Sub View_SO (CAPTION as String) 'I need to extract 123456 based on which button exists and pass ' it to the subroutine v = split(CAPTION,"=",2) 'Go do stuff with v(1) 

任何帮助表示赞赏。

Application.Caller会给你这个button的名字