ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Get / extract a button name (https://www.excelbanter.com/excel-programming/325429-get-extract-button-name.html)

Oener

Get / extract a button name
 
Hi,

I have a button "C2".
I want to get the name of the button in VBA to point on the cell C2.
How do I get the name of the button without using the name of the button?

With use:
Dim whatIwant as variant
whatIwant = Me.C2.Name
-- whatIwant=C2

is there a way like:
whatIwant = Mebutton.Name
???

Kindly
Oener

ben

Get / extract a button name
 
You want to get the name without using the name???? Sorry not quite certain
what you are asking for.
you could loop through all the controls on the userform and see if any of
them match criteria
dim con as control
for each con in me.controls
if 'criteria code here
whatiwant = con.name
end if
next

ben

"Oener" wrote:

Hi,

I have a button "C2".
I want to get the name of the button in VBA to point on the cell C2.
How do I get the name of the button without using the name of the button?

With use:
Dim whatIwant as variant
whatIwant = Me.C2.Name
-- whatIwant=C2

is there a way like:
whatIwant = Mebutton.Name
???

Kindly
Oener


Oener

Get / extract a button name
 
The problem is much greater:
I have a field C2 ").
With a click on a button, Outlook generates an email with Body, Subject,
Attachment and Signatur. But I want that the email-Adress for the To-Field is
taken from C2.

Therefore I thought, that I can provide this field dynamic, so that VBA
takes the Name of the Button (in this Case C2) and after that it chooses the
field C2, lookes inside, takes the adress in C2 and puts it in the To-Field!

Do I want to much?
I know everything about that process but now idea how to query the the name
of the button in that button.

So I hope someone can help me.

"ben" wrote:

You want to get the name without using the name???? Sorry not quite certain
what you are asking for.
you could loop through all the controls on the userform and see if any of
them match criteria
dim con as control
for each con in me.controls
if 'criteria code here
whatiwant = con.name
end if
next

ben

"Oener" wrote:

Hi,

I have a button "C2".
I want to get the name of the button in VBA to point on the cell C2.
How do I get the name of the button without using the name of the button?

With use:
Dim whatIwant as variant
whatIwant = Me.C2.Name
-- whatIwant=C2

is there a way like:
whatIwant = Mebutton.Name
???

Kindly
Oener



All times are GMT +1. The time now is 03:16 AM.

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