PC Review


Reply
Thread Tools Rate Thread

How to call a macro with a flexible name

 
 
=?Utf-8?B?QWxleCBTdC1QaWVycmU=?=
Guest
Posts: n/a
 
      23rd Nov 2006
Hi,
I have 10 differents macro that create tables.
ex: Sub CreateT1_1(iSheetPos as integer), CreateT1_2(iSheetPos as integer),
etc.
Is there a way to say:
sMacroName = "CreateT1_1"
Call sMacroName(iSheetPos)
....
Application.Run works but it close my form at the end of the execution.
Also, is there a way to test if the Macro Exist?
I tried:
On Error Resume Next
Application.Run sMacroName, iSheetPos
Msgbox(err.number) ' This show always 0 even if sMacroName doesn't exist!
Thanks!
--
Alex St-Pierre
 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      23rd Nov 2006


"Alex St-Pierre" <(E-Mail Removed)> wrote in message
newsBF3086C-B92E-4F3D-9BC3-(E-Mail Removed)...
> Hi,
> I have 10 differents macro that create tables.
> ex: Sub CreateT1_1(iSheetPos as integer), CreateT1_2(iSheetPos as

integer),
> etc.
> Is there a way to say:
> sMacroName = "CreateT1_1"
> Call sMacroName(iSheetPos)
> ...
> Application.Run works but it close my form at the end of the execution.



How? Show the code.


> Also, is there a way to test if the Macro Exist?
> I tried:
> On Error Resume Next
> Application.Run sMacroName, iSheetPos
> Msgbox(err.number) ' This show always 0 even if sMacroName doesn't exist!



If you made it a function that returns 1 , you could set a variable to 0,
and then run and test it

myVar = 0
On Error Resume Next
myVar = Application.Run(sMacroName, iSheetPos)
On Error Goto 0
If myVar = 0 Then
...



 
Reply With Quote
 
=?Utf-8?B?QWxleCBTdC1QaWVycmU=?=
Guest
Posts: n/a
 
      23rd Nov 2006
Thanks !!
This works very well.
Alex

"Bob Phillips" wrote:

>
>
> "Alex St-Pierre" <(E-Mail Removed)> wrote in message
> newsBF3086C-B92E-4F3D-9BC3-(E-Mail Removed)...
> > Hi,
> > I have 10 differents macro that create tables.
> > ex: Sub CreateT1_1(iSheetPos as integer), CreateT1_2(iSheetPos as

> integer),
> > etc.
> > Is there a way to say:
> > sMacroName = "CreateT1_1"
> > Call sMacroName(iSheetPos)
> > ...
> > Application.Run works but it close my form at the end of the execution.

>
>
> How? Show the code.
>
>
> > Also, is there a way to test if the Macro Exist?
> > I tried:
> > On Error Resume Next
> > Application.Run sMacroName, iSheetPos
> > Msgbox(err.number) ' This show always 0 even if sMacroName doesn't exist!

>
>
> If you made it a function that returns 1 , you could set a variable to 0,
> and then run and test it
>
> myVar = 0
> On Error Resume Next
> myVar = Application.Run(sMacroName, iSheetPos)
> On Error Goto 0
> If myVar = 0 Then
> ...
>
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Flexible autofill in macro Pluggie Microsoft Excel Programming 3 3rd Nov 2010 08:20 PM
Flexible X axis VBA/Macro generated duncan beech Microsoft Excel Charting 1 2nd Mar 2009 09:45 PM
Call macro stored in Excel workbook from Outlook's macro =?Utf-8?B?R3ZhcmFt?= Microsoft Outlook VBA Programming 5 4th Oct 2006 06:26 AM
Making the macro more flexible? mariasa Microsoft Excel Programming 3 18th Mar 2006 06:50 AM
VBA - Flexible Sort Macro jordanctc Microsoft Excel Programming 2 26th Aug 2004 04:32 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:04 PM.