ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Call Event and Load Form based on Variable (https://www.excelbanter.com/excel-programming/356040-call-event-load-form-based-variable.html)

Resant

Call Event and Load Form based on Variable
 
Hi all,
I have some problem with dynamic things :
1) I need to call an event which the event name was saved in a
variable.
Eg :
Dim sEventName as String
sEventName = "Button1_Click"

Call sEventName

2) And how to load Form based on variable too?
Eg :
Dim sFormName as String
sFormName = "Form1"

Load sFormName

Hope someone can help me to solve the problems.

Thanks a lot!

Resant


Tom Ogilvy

Call Event and Load Form based on Variable
 
use Application.run

Application.Run sEventName


http://support.microsoft.com/kb/157609/en-us
XL97: How to Display a UserForm Whose Name Is in a Variable

--
Regards,
Tom Ogilvy




"Resant" wrote in message
ups.com...
Hi all,
I have some problem with dynamic things :
1) I need to call an event which the event name was saved in a
variable.
Eg :
Dim sEventName as String
sEventName = "Button1_Click"

Call sEventName

2) And how to load Form based on variable too?
Eg :
Dim sFormName as String
sFormName = "Form1"

Load sFormName

Hope someone can help me to solve the problems.

Thanks a lot!

Resant




Resant

Call Event and Load Form based on Variable
 
Wonderful!
You save my time...
Thanks a lot Tom


Resant

Call Event and Load Form based on Variable
 
Tom,
More question....
Is there any coding that could tell what the last macro that have been
run from other Workbook?

Thanks,

Resant


Tom Ogilvy

Call Event and Load Form based on Variable
 
Not Unless you have the macro write that information someplace where you can
access it; there is no built in support for it.

--
Regards,
Tom Ogilvy

"Resant" wrote:

Tom,
More question....
Is there any coding that could tell what the last macro that have been
run from other Workbook?

Thanks,

Resant




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

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