我有一个函数,可以生成100个单元格行(和2列)的数据.对于每一行(在第3列中),我需要添加一个按钮,当单击该按钮时,会弹出一个自定义模式对话框,为用户提供4个选项/按钮供您选择.
知道怎么做吗?
/ T
Dr.*_*ius 91
我认为这足以让你走上一条不错的道路:
Sub a()
Dim btn As Button
Application.ScreenUpdating = False
ActiveSheet.Buttons.Delete
Dim t As Range
For i = 2 To 6 Step 2
Set t = ActiveSheet.Range(Cells(i, 3), Cells(i, 3))
Set btn = ActiveSheet.Buttons.Add(t.Left, t.Top, t.Width, t.Height)
With btn
.OnAction = "btnS"
.Caption = "Btn " & i
.Name = "Btn" & i
End With
Next i
Application.ScreenUpdating = True
End Sub
Sub btnS()
MsgBox Application.Caller
End Sub
Run Code Online (Sandbox Code Playgroud)
它创建按钮并将它们绑定到butnS().在btnS()子程序中,您应该显示对话框等.
