Calling a sub from another sub - passing variables

vbacoder

Active Member
Joined
Jul 7, 2007
Messages
354
Hi everyone,

I am having problems with the syntax involved in calling one subroutine from within another. I want to pass two variables calculated in a 'main' sub into the parentheses of another I am calling (see pseudocode below). When I pass one variable, everything works fine, however, when I try to include another, I get an error message - something about expecting an "=" in the syntax, which is clearly not correct.

Sub main()

row = .....

column = .....

counting(row, column)

End sub()


Sub counting (row, column)

.....


End sub

Many thanks,

vcoder
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Drop the ().

And don't use things like row/column for variable names.
 
Upvote 0
Hi guys,

Thanks for your replies.

Norie - rows & columns were just an e.g. off the top of my mind. I have other data and variable names in the real sheet. So would counting row, column work?

VoG II - This looks like a FTN trick ;) Thanks, I'll try it!

Many thanks for your help again!

vcoder
 
Upvote 0
Ah, right get what you mean now.:oops:

Yes this should work.
Code:
counting row, column
PS When posting code it's normally better to post the actual code.:)
 
Upvote 0
I always use the Call mysub(x,y,...) syntax and - yes - I was brought up on Fortran in the last century.
 
Upvote 0

Forum statistics

Threads
1,213,531
Messages
6,114,172
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top