cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

global variables

AD_10841348
4-Participant

global variables

Why am I getting an error when I move g below k? Shouldn't global variables work where ever they are used?

 

2.jpg  -->  1.jpg

 

so, this seems to work ... 3.jpg... So is it not possible to have global variables inside global variables? if so, why did the first set of calcs work?

 

 

Thank you in advance

1 ACCEPTED SOLUTION

Accepted Solutions

When a worksheet is evaluated it is read twice. In the first scan global assignments are collected, the second run deals with the rest.

So for global definitions the same rules apply as for normal ones. The sheet is read left to right, top down. So when the global(!) definition of h makes use of the globally(!) defined constant f, then f has to be defined in front or to the left of the definition of h.

 

BTW, it has proven a good advice over the years to use global definition with great care and as sparingly as possible.

View solution in original post

1 REPLY 1

When a worksheet is evaluated it is read twice. In the first scan global assignments are collected, the second run deals with the rest.

So for global definitions the same rules apply as for normal ones. The sheet is read left to right, top down. So when the global(!) definition of h makes use of the globally(!) defined constant f, then f has to be defined in front or to the left of the definition of h.

 

BTW, it has proven a good advice over the years to use global definition with great care and as sparingly as possible.

Top Tags