ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Run or Call a sub from the list of subs in a drop down. (https://www.excelbanter.com/excel-programming/449312-run-call-sub-list-subs-drop-down.html)

Howard

Run or Call a sub from the list of subs in a drop down.
 
If I have a list of ten sub names in a drop down F1, can I make my MySubCaller run the sub I choose in F1?

This little diddy doesn't work and the scant info I can find to do this leads me to think it is a bogus way to manage the running of ten subs from a single on sheet button.

Thanks,
Howard

Option Explicit

Sub MySubCaller()
Dim i As String
i = Range("F1").Value
Application.Run i
End Sub

Howard

Run or Call a sub from the list of subs in a drop down.
 
On Sunday, September 29, 2013 10:48:37 PM UTC-7, Howard wrote:
If I have a list of ten sub names in a drop down F1, can I make my MySubCaller run the sub I choose in F1?



This little diddy doesn't work and the scant info I can find to do this leads me to think it is a bogus way to manage the running of ten subs from a single on sheet button.



Thanks,

Howard



Option Explicit



Sub MySubCaller()

Dim i As String

i = Range("F1").Value

Application.Run i

End Sub


I found this but I still get an error 400 with:

Application.Run (i)


expression .Run(Macro,[Arg1, , , Arg30])
expression A variable that represents an Application object

Howard

Claus Busch

Run or Call a sub from the list of subs in a drop down.
 
Hi Howard,

Am Sun, 29 Sep 2013 23:14:45 -0700 (PDT) schrieb Howard:

Application.Run (i)


try worksheet_change event:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address < "$F$1" Then Exit Sub

Application.Run (Target)
End Sub


Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2

Howard

Run or Call a sub from the list of subs in a drop down.
 
On Monday, September 30, 2013 12:12:49 AM UTC-7, Claus Busch wrote:
Hi Howard,



Am Sun, 29 Sep 2013 23:14:45 -0700 (PDT) schrieb Howard:



Application.Run (i)




try worksheet_change event:



Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address < "$F$1" Then Exit Sub



Application.Run (Target)

End Sub





Regards

Claus B.


With this in the sheet 1 module I get an error on the App.Run(Target) line
saying macros may not be available or may be disabled.
(There are three more macros like the one shown)

Howard

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address < "$F$1" Then Exit Sub
Application.Run (Target)
End Sub

Sub xx1()
MsgBox "one"
End Sub

Claus Busch

Run or Call a sub from the list of subs in a drop down.
 
Hi Howard,

Am Mon, 30 Sep 2013 01:11:37 -0700 (PDT) schrieb Howard:

With this in the sheet 1 module I get an error on the App.Run(Target) line
saying macros may not be available or may be disabled.
(There are three more macros like the one shown)


please have a look:
https://skydrive.live.com/#cid=9378A...121822A3%21326
for the workbook "Macro". Download it with rightclick


Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2

Claus Busch

Run or Call a sub from the list of subs in a drop down.
 
Hi Howard,

Am Mon, 30 Sep 2013 01:11:37 -0700 (PDT) schrieb Howard:

Sub xx1()


xx1 is a cell reference. You can't name a macro like a cell reference


Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2

Claus Busch

Run or Call a sub from the list of subs in a drop down.
 
Hi Howard,

Am Mon, 30 Sep 2013 10:35:40 +0200 schrieb Claus Busch:

xx1 is a cell reference. You can't name a macro like a cell reference


a macro named like a cell reference you can run from VBA editor.
If you try to run it from a sheet you can't, because the Run button is
disabled.


Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2

Howard

Run or Call a sub from the list of subs in a drop down.
 
On Monday, September 30, 2013 2:06:43 AM UTC-7, Claus Busch wrote:
Hi Howard,



Am Mon, 30 Sep 2013 10:35:40 +0200 schrieb Claus Busch:



xx1 is a cell reference. You can't name a macro like a cell reference




a macro named like a cell reference you can run from VBA editor.

If you try to run it from a sheet you can't, because the Run button is

disabled.





Regards

Claus B.


Boy do I feel stupid. In my haste I just wanted to create four or five macros to set up my code. Completely over looked the cell ref's I was using.

Thanks Claus.

Regards,
Howard
Howard

GS[_2_]

Run or Call a sub from the list of subs in a drop down.
 
On Monday, September 30, 2013 2:06:43 AM UTC-7, Claus Busch wrote:
Hi Howard,



Am Mon, 30 Sep 2013 10:35:40 +0200 schrieb Claus Busch:



xx1 is a cell reference. You can't name a macro like a cell
reference




a macro named like a cell reference you can run from VBA editor.

If you try to run it from a sheet you can't, because the Run button
is

disabled.





Regards

Claus B.


Boy do I feel stupid. In my haste I just wanted to create four or
five macros to set up my code. Completely over looked the cell ref's
I was using.

Thanks Claus.

Regards,
Howard
Howard


Test1()
Test2()
Test3()
Test4()
Test5()

OR as does the macro recorder...

Macro1()
Macro2()
Macro3()
Macro4()
Macro5()

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion




All times are GMT +1. The time now is 02:21 AM.

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