Thread: Calling a sub
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Leith Ross[_794_] Leith Ross[_794_] is offline
external usenet poster
 
Posts: 1
Default Calling a sub


Dave;479036 Wrote:
Hi,
XL 2003
I'm trying to call a subroutine using a variable to name part of the
subroutine, but I can't find a syntax that works.
ie:
I have several sorting Subs called SortByA, SortByB, SortByC etc
Using an input box, the user is prompted to enter a letter, which I
assign
to the variable: 'answer'
I then want to call one of the Subs, like this:
Call "SortBy" & answer
But the above syntax (and lots of others) were rejected.
Can this be done?
Regards - Dave.


Hello Dave,

You can do this using "Application.Run"

Application.Run "SortBy" & Answer


--
Leith Ross

Sincerely,
Leith Ross

'The Code Cage' (http://www.thecodecage.com/)
------------------------------------------------------------------------
Leith Ross's Profile: http://www.thecodecage.com/forumz/member.php?userid=75
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=132122