can some1 pls help me? i m beginner in writing some marco.
below r my code
how to pass the x=10 to sub part1?Please Login or Register to view this content.
can some1 pls help me? i m beginner in writing some marco.
below r my code
how to pass the x=10 to sub part1?Please Login or Register to view this content.
Last edited by royUK; 05-13-2008 at 12:58 PM.
Are both of those procedures in the same Worksheet module, or is the second in a general module?
If they are both in the same module, you would need to declare the variable at the top of the module, outside the other procedures.
If they are in different modules, you will need to declare it as a public variable at the top of a general module.Please Login or Register to view this content.
Worksheet module:
General module:Please Login or Register to view this content.
HTHPlease Login or Register to view this content.
Jason
I reckon you should declare the x = 10 outside the sub at the very top that ways its public and can be used by any sub routine
Mr MaGoo
Magoo.Inc MMVII
If i've helped please add to my Rep by Clicking on the Blue Scales in the top right hand corner of the post
Hi,Originally Posted by ccs_1981
I note your thread title was asking how to pass a parameter to another sub. The replies you've had, whilst achieving what you want, rely on explicitly declaring a variable, using that and ensuring that it is a) still in scope, and b) its 'life' hasn't passed.
Passing a parameter is somewhat different. The pair of brackets that you see at the end of every Procedure name, e.g. MyFantasticProcedure() are where the receiving Procedure defines the value that's being passed. So for instance if you want to pass the number 10, you'd use the following code.
and the MyF..P... would bePlease Login or Register to view this content.
Please Login or Register to view this content.
HTH
ccs_1981
Please read the Forum Rules & wrap your code with Code tags in future.
Hope that helps.
RoyUK
--------
For Excel Tips & Solutions, free examples and tutorials why not check out my web site
Free DataBaseForm example
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks