ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   sub call with string (https://www.excelbanter.com/excel-programming/332052-sub-call-string.html)

Aran

sub call with string
 
hello
i have a combobox were i chose a value and like to run a sub
were the name of the value is the name of the sub
how do i do



JMB

sub call with string
 
try using

Application.Run (MacroName)


"aran" wrote:

hello
i have a combobox were i chose a value and like to run a sub
were the name of the value is the name of the sub
how do i do



Aran

sub call with string
 
Hello thanks
that seem to work on macros but if i like too run a sub in the same sheet

"JMB" wrote:

try using

Application.Run (MacroName)


"aran" wrote:

hello
i have a combobox were i chose a value and like to run a sub
were the name of the value is the name of the sub
how do i do



JMB

sub call with string
 
A sub in the same sheet? Is the sub an event handler or just a regular
macro? If it's just a regular macro I'd move it to a regular module (I don't
think VBA looks for plain-vanilla macros in the sheet modules). If you're
trying to call an event handler, can you move the guts of your second event
handler to a macro in a standard module and replace with a call to the macro
(ie both event handlers would call the same macro).


"aran" wrote:

Hello thanks
that seem to work on macros but if i like too run a sub in the same sheet

"JMB" wrote:

try using

Application.Run (MacroName)


"aran" wrote:

hello
i have a combobox were i chose a value and like to run a sub
were the name of the value is the name of the sub
how do i do



Aran

sub call with string
 
Thanks
Is it better to have the most subs in module
and can i have as many subs i want in one module

"JMB" wrote:

A sub in the same sheet? Is the sub an event handler or just a regular
macro? If it's just a regular macro I'd move it to a regular module (I don't
think VBA looks for plain-vanilla macros in the sheet modules). If you're
trying to call an event handler, can you move the guts of your second event
handler to a macro in a standard module and replace with a call to the macro
(ie both event handlers would call the same macro).


"aran" wrote:

Hello thanks
that seem to work on macros but if i like too run a sub in the same sheet

"JMB" wrote:

try using

Application.Run (MacroName)


"aran" wrote:

hello
i have a combobox were i chose a value and like to run a sub
were the name of the value is the name of the sub
how do i do



JMB

sub call with string
 
I have not run into problems with limits on the number of macros in a module.
If you want, you can add more modules. I've never run into problems w/not
being able to add enough modules either.

I think it's better practice to keep your macros and functions in standard
code modules and your worksheet level event handlers in your worksheet
modules. Excel doesn't always look for a public macro in a worksheet module.
If you create a button using the forms toolbar, you cannot assign any macros
from the worksheet modules - Excel does not make those available, which makes
sense as event handlers cannot be called in that fashion.




"aran" wrote:

Thanks
Is it better to have the most subs in module
and can i have as many subs i want in one module

"JMB" wrote:

A sub in the same sheet? Is the sub an event handler or just a regular
macro? If it's just a regular macro I'd move it to a regular module (I don't
think VBA looks for plain-vanilla macros in the sheet modules). If you're
trying to call an event handler, can you move the guts of your second event
handler to a macro in a standard module and replace with a call to the macro
(ie both event handlers would call the same macro).


"aran" wrote:

Hello thanks
that seem to work on macros but if i like too run a sub in the same sheet

"JMB" wrote:

try using

Application.Run (MacroName)


"aran" wrote:

hello
i have a combobox were i chose a value and like to run a sub
were the name of the value is the name of the sub
how do i do




All times are GMT +1. The time now is 07:20 PM.

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