Variable in call statement

D

donwb

In Excel 2003, a statement <<Call SomeModule>>
will do just that and execute the code in <<Sub SomeModule.>>
Is it possible for the Call statement to comprise a fixed portion
AND a variable something like:-
Call Some & "Variable"
donwb
 
C

Chip Pearson

You don't need to use the Call keyword. You can use only the procedure
name. However, some folks like using Call, so do with it as you like.
Try code like

Sub AAA()
Call SomeOtherProc("abc",123)
' more code
End Sub

' Or

Sub AAA()
SomeOtherProc "abc",123
' more code
End Sub

If you are using the Call statement, you must enclose parameter list
within parentheses. If you do not use Call, you do not use the
parentheses when calling a Sub, since a Sub doesn't return a value.
But if you are calling a Function, you enclose the parameter list in
parentheses. E.g,

Dim V As Variant
V = SomeFunction("abc",123)

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
S

Sheeloo

Chip,

I think what Don wants is to call procedures like
i=1
call test & i

assuming he has
test1
test2
..
..
..
as procedures
 
D

donwb

Hi Chip & Sheeloo

Chip thanks for the input - I'm ok with the with and without parenthesis

But still have the problem.

Sheeloo - you're right - that's what I'm trying to do and I do have Test1 &
Test2

but either the syntax is wrong or it's not possible.

donwb
 
C

Chip Pearson

Yeah, you're right. I missed the boat on that one.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
D

donwb

Many thanks Sheeloo for the answer:
that works fine.
Can't find <<Yes>> to click it,
though I know it's there somewhere.
donwb
 
S

Sheeloo

You see it only if you access the post through a browser... The only reason I
request an 'Yes' that it helps other who have similar issues.

Glad you got what you were looking for.
 
R

Rick Rothstein

Perhaps you should consider adjusting your signature to reflect this;
something like this maybe...

If you are viewing this response in a browser...
please click ''''Yes'''' if this answer was helpful.
 
S

Sheeloo

See the updated message below...

Is it appropriate even to ask for an 'Yes' response?


--

Pl click the ''Yes'' button,
- if you see it (don''t worry if you don''t) -
if this answer was helpful.
 
S

Sheeloo

Thanks for your response... I just pointed it out hoping to learn something
new...

Do you think it is appropriate to ask for an 'Yes' response? I have also
asked Rick...
 
R

Rick Rothstein

I don't see why it wouldn't be appropriate... you are simply alerting
readers to the option and they are under no obligation to listen to your
request.
 
D

donwb

I access this News Group thru OutlookExpress
so presumably that's why I don't see "Click Yes"
donwb
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top