N
Neal Zimm
Am still pretty new to the VBA Excel game, and thought I understood enough
about scope, the declarations sections, and passing values between called
procedures, but I guess not. I have read most of the dupe declar postings as
well as Excel help a couple of times and it has not helped, so.....
I have two workbooks, a 'production' book (prod) and a test workbook.
I have them both open in the same window, (i don't know if this has a
bearing on the problem or solution.)
I copy the declarations procedure from prod to test, develop and do prelim
testing in the test workbook, and then move or copy the new stuff back to
prod.
in test, I am getting a dupe declare compile error on hserow in the following:
Sub zStrt_Hse(hserow, fromcol,ResultVar)
Dim hserow As Integer
'other code
Using project explorer find at the project level, the ONLY dim statement for
hserow i find is in the module above. So how can I be getting a dupe declare
error?
(I have run other macros that use hserow in the same excel session, could
that be it?, I do not use any static variables.)
My intention is to have the calling procedure look like what's below, BUT
the code below was not written at the time of the above dupe declare error,
so transrow and basecol have not been dim'd yet.(I don't think this has a
bearing on my problem, but I just don't know.)
transrow = whatever
basecol = whatever
call zStrt_Hse(transrow, basecol,Answer) 'And zStrt_Hse will do its thing
To get around this problem, I know that I can declare the vars in the
declarations section and avoid the problem altogether, but from what I've
read this is not a great habit to get into.
Am I right, in that if done that way, I can use the SAME variable names and
the call would look like.
call zStrt_Hse or even just zStrt_Hse
I am looking for the simplest way to do this where the life of the value of
the variable named in the called sub does NOT matter after the called routine
ends.
The value in the calling routine does usually matter for me. (transrow and
basecol in the examples above.)
Thanks,
about scope, the declarations sections, and passing values between called
procedures, but I guess not. I have read most of the dupe declar postings as
well as Excel help a couple of times and it has not helped, so.....
I have two workbooks, a 'production' book (prod) and a test workbook.
I have them both open in the same window, (i don't know if this has a
bearing on the problem or solution.)
I copy the declarations procedure from prod to test, develop and do prelim
testing in the test workbook, and then move or copy the new stuff back to
prod.
in test, I am getting a dupe declare compile error on hserow in the following:
Sub zStrt_Hse(hserow, fromcol,ResultVar)
Dim hserow As Integer
'other code
Using project explorer find at the project level, the ONLY dim statement for
hserow i find is in the module above. So how can I be getting a dupe declare
error?
(I have run other macros that use hserow in the same excel session, could
that be it?, I do not use any static variables.)
My intention is to have the calling procedure look like what's below, BUT
the code below was not written at the time of the above dupe declare error,
so transrow and basecol have not been dim'd yet.(I don't think this has a
bearing on my problem, but I just don't know.)
transrow = whatever
basecol = whatever
call zStrt_Hse(transrow, basecol,Answer) 'And zStrt_Hse will do its thing
To get around this problem, I know that I can declare the vars in the
declarations section and avoid the problem altogether, but from what I've
read this is not a great habit to get into.
Am I right, in that if done that way, I can use the SAME variable names and
the call would look like.
call zStrt_Hse or even just zStrt_Hse
I am looking for the simplest way to do this where the life of the value of
the variable named in the called sub does NOT matter after the called routine
ends.
The value in the calling routine does usually matter for me. (transrow and
basecol in the examples above.)
Thanks,