Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 169
Default How to call a macro with a flexible name

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default How to call a macro with a flexible name



"Alex St-Pierre" wrote in message
...
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
...



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 169
Default How to call a macro with a flexible name

Thanks !!
This works very well.
Alex

"Bob Phillips" wrote:



"Alex St-Pierre" wrote in message
...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Flexible X axis VBA/Macro generated duncan beech Charts and Charting in Excel 1 March 2nd 09 09:45 PM
Excel Macro call Word Macro with Parameters Bill Sturdevant[_2_] Excel Programming 9 May 24th 07 12:21 AM
Call macro stored in Excel workbook from Outlook's macro Gvaram Excel Programming 0 October 4th 06 05:47 PM
Making the macro more flexible? mariasa[_20_] Excel Programming 3 March 18th 06 06:50 AM
VBA - Flexible Sort Macro jordanctc[_10_] Excel Programming 2 August 26th 04 04:32 PM


All times are GMT +1. The time now is 05:39 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"