ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Retriving name of cobntrolelement (https://www.excelbanter.com/excel-programming/363796-retriving-name-cobntrolelement.html)

Jan Kronsell

Retriving name of cobntrolelement
 
I have to pass the name of a controlelement as argument to a sub.But how do
i retrive the name of the control element. within the elements Click-event.
What I like is something like this:

Private Sub CheckBox0_Click()
Call NewSub("ActiveControl")
End Sub

In this case, the name of the active control is Checkbox(0), and the problem
could be solved using:

Private Sub CheckBox0_Click()
Call NewSub("Checkbox(0)")
End Sub

but I would like to be able to use the same code fro a lot of
controlelements, without having to hardcode all the names.

Regards
Jan




Gary L Brown

Retriving name of cobntrolelement
 
If it's on a form.

Call NewSub(Me.ActiveControl.name)

hth,
--
Gary Brown

If this post was helpful, please click the ''Yes'' button next to ''Was this
Post Helpfull to you?''.


"Jan Kronsell" wrote:

I have to pass the name of a controlelement as argument to a sub.But how do
i retrive the name of the control element. within the elements Click-event.
What I like is something like this:

Private Sub CheckBox0_Click()
Call NewSub("ActiveControl")
End Sub

In this case, the name of the active control is Checkbox(0), and the problem
could be solved using:

Private Sub CheckBox0_Click()
Call NewSub("Checkbox(0)")
End Sub

but I would like to be able to use the same code fro a lot of
controlelements, without having to hardcode all the names.

Regards
Jan






All times are GMT +1. The time now is 06:40 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com