VBA代码不会正确返回按钮行

时间:2015-07-16 01:27:15

标签: vba excel-vba excel

以下代码在我的电子表格中动态创建按钮

  1. how is it compiled ?
  2. What does CoreClr do?
  3. how is CoreClr different from Clr
  4. What happens when we do dnu restore
  5. what happens when we do dnx . exe
  6. At what stage is the CIL generated , where is the CIL stored 
  7. At what stage the JIT is used?

每个按钮将运行相同的宏,该宏仅在单击按钮的行中起作用,因此我使用下面的代码获取所单击按钮的行:

Sub CreateButton(ButtonName As String, Rng As Range, Macro As String)
    ActiveSheet.Buttons.Add(Rng.Left, Rng.Top, Rng.Width, Rng.Height).Select
    With Selection
        .Characters.Text = ButtonName
        .OnAction = Macro
        .Name = ButtonName & Rng
    End With
End Sub

Sub LetsCreateAButton()
    CreateButton("Example", Range("A1"), "RunMacro")
End Sub

但有时我会得到当前行的编号,有时我会得到列中第一个按钮的行数。谁知道出了什么问题?

0 个答案:

没有答案