Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8
Default Calling a procudure through variable name

Hi All,

I have run into a problem that I thought didn't exist. WIll appreciate
if anyone can give pointers.

Here is what I am doing. I have three combo boxes which the user
selects. I concatenate all of them togather to form a string. I now
want to call a procedure that is the same value as the concatenated
string. For example if the the combo boxes are box1, box2 and box3 and
there values are Australia, AP, BIZ the the final string is
Australia_AP_BIZ and there exists a procedure by that name. Then I
call the procedure with call to_proc where the to_proc variable
contains the above string. I expected xl to call the above procedure,
however guess what I got an error stating that it expected procedure
not variable.

Is there anyway I can make xl understand that I want to call a
procedure by the name that is stored in the variable?

Will appreciate any pointers as I have developed this since I need to
call more than 300 functions which are formed by the combination of the
combo boxes, and it is not possible (rather cumbersome) to write so
many select clauses.


Regards

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,441
Default Calling a procudure through variable name

Basu,

Try using application.run.

Sub TryNow()
Str1 = "Procedure"
Str2 = "V2"
Application.Run Str1 & "_" & Str2
End Sub

Sub Procedure_V2()
MsgBox "Hello World"
End Sub

HTH,
Bernie
MS Excel MVP


"Basu" wrote in message
oups.com...
Hi All,

I have run into a problem that I thought didn't exist. WIll appreciate
if anyone can give pointers.

Here is what I am doing. I have three combo boxes which the user
selects. I concatenate all of them togather to form a string. I now
want to call a procedure that is the same value as the concatenated
string. For example if the the combo boxes are box1, box2 and box3 and
there values are Australia, AP, BIZ the the final string is
Australia_AP_BIZ and there exists a procedure by that name. Then I
call the procedure with call to_proc where the to_proc variable
contains the above string. I expected xl to call the above procedure,
however guess what I got an error stating that it expected procedure
not variable.

Is there anyway I can make xl understand that I want to call a
procedure by the name that is stored in the variable?

Will appreciate any pointers as I have developed this since I need to
call more than 300 functions which are formed by the combination of the
combo boxes, and it is not possible (rather cumbersome) to write so
many select clauses.


Regards



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8
Default Calling a procudure through variable name

Hi Bernie,

Works like a charm.... Thanks for the timely help. Much appreciated.

Regards
Shuvro


Bernie Deitrick wrote:
Basu,

Try using application.run.

Sub TryNow()
Str1 = "Procedure"
Str2 = "V2"
Application.Run Str1 & "_" & Str2
End Sub

Sub Procedure_V2()
MsgBox "Hello World"
End Sub

HTH,
Bernie
MS Excel MVP


"Basu" wrote in message
oups.com...
Hi All,

I have run into a problem that I thought didn't exist. WIll appreciate
if anyone can give pointers.

Here is what I am doing. I have three combo boxes which the user
selects. I concatenate all of them togather to form a string. I now
want to call a procedure that is the same value as the concatenated
string. For example if the the combo boxes are box1, box2 and box3 and
there values are Australia, AP, BIZ the the final string is
Australia_AP_BIZ and there exists a procedure by that name. Then I
call the procedure with call to_proc where the to_proc variable
contains the above string. I expected xl to call the above procedure,
however guess what I got an error stating that it expected procedure
not variable.

Is there anyway I can make xl understand that I want to call a
procedure by the name that is stored in the variable?

Will appreciate any pointers as I have developed this since I need to
call more than 300 functions which are formed by the combination of the
combo boxes, and it is not possible (rather cumbersome) to write so
many select clauses.


Regards


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
calling variable within string [email protected] Excel Worksheet Functions 8 May 4th 06 03:07 PM
Aling multiple sets of data by header column MarkusO Excel Discussion (Misc queries) 2 April 12th 06 07:29 PM
variable height variable width stacked bar charts ambthiru Charts and Charting in Excel 3 January 18th 06 11:41 PM
object variable or with block variable not set Diego Excel Discussion (Misc queries) 1 August 9th 05 02:46 PM
I Need VBA Assistance for global variable question Brent E Excel Discussion (Misc queries) 1 March 1st 05 08:46 PM


All times are GMT +1. The time now is 11:32 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"