ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Automatically Assigning a Macro to a button (https://www.excelbanter.com/excel-programming/296154-automatically-assigning-macro-button.html)

David

Automatically Assigning a Macro to a button
 
Hi, this is my first post on Google groups, here goes, I have this
program that, given a lifespan of years say from 2004 to 2008, it
creates a sheet for each year, then it creates a button for each sheet
on the "Cover Sheet". What i'm trying to do is to get my program to
assign a macro to each button that takes it to its corresponding
sheet. I can get it to assign a macro to it but the macro doesn't
know what sheet the button is supposed to send you to. I was thinking
if i can read the name of the button put it into a variable in the
little macro takes you to whatever page then do a Sheets().Select with
the variable name in the parenthesis. Problem is I don't know how to
read the buttons name. I just want one macro that can be flexible
enough to take you to any sheet given the buttons name. Any help would
be greatly appreciated, thank you.

Greg Wilson[_4_]

Automatically Assigning a Macro to a button
 
The statement Application.Caller will return the name of
the button that called the procedure as a string; e.g.
MsgBox Application.Caller will return the message "Button
1" if this is its name.

Regards,
Greg

-----Original Message-----
Hi, this is my first post on Google groups, here goes, I

have this
program that, given a lifespan of years say from 2004 to

2008, it
creates a sheet for each year, then it creates a button

for each sheet
on the "Cover Sheet". What i'm trying to do is to get my

program to
assign a macro to each button that takes it to its

corresponding
sheet. I can get it to assign a macro to it but the

macro doesn't
know what sheet the button is supposed to send you to. I

was thinking
if i can read the name of the button put it into a

variable in the
little macro takes you to whatever page then do a Sheets

().Select with
the variable name in the parenthesis. Problem is I don't

know how to
read the buttons name. I just want one macro that can be

flexible
enough to take you to any sheet given the buttons name.

Any help would
be greatly appreciated, thank you.
.



All times are GMT +1. The time now is 12:24 PM.

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