获取Button接口对象对应的Range [英] Get corresponding Range for Button interface object
本文介绍了获取Button接口对象对应的Range的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我点击Sélectionner un poste"按钮时,我想要它会告诉我位置.(我在哪一行点击的按钮.)
I want when I click the button "Sélectionner un poste" it will tell me the position. (The button which I clicked in which row.)
创建按钮的代码:
Sub AjouterBoutonPoste(positionX As Integer, positionY As Integer, nom As String)
Set t = ActiveSheet.Range(Cells(positionX, positionY), Cells(positionX, positionY))
Set btn = ActiveSheet.Buttons.Add(t.Left, t.Top, t.Width, t.Height)
With btn
.OnAction = "PosteBtAction"
.Caption = "Sélectionner un poste"
.Name = nom & CStr(positionX) & CStr(positionY)
End With
End Sub
事件按钮代码:
Sub PosteBtAction()
AssocierSessoinCandidature.Show
End Sub
我有一个名为 AssocierSessoinCandidature
的应用程序窗口.我想要我点击的位置发送到应用程序窗口.
I have an application window named AssocierSessoinCandidature
. I want the position which I clicked sent to the application window.
这是我的 Excel 表格示例:
Here is my example Excel sheet:
推荐答案
点击按钮时调用下面的Sub
Call the below Sub when the button is clicked
Sub foo()
Dim obj As Object
Dim row_no As Integer
Set obj = ActiveSheet.Buttons(Application.Caller)
With obj.TopLeftCell
row_no = .Row
End With
MsgBox "The Button is in the row number " & row_no
End Sub
这篇关于获取Button接口对象对应的Range的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文