LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 345
Default Declarations Procedure and Duplicate Declarations

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,
--
Neal Z
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Understanding declarations Greg[_16_] Excel Programming 1 January 26th 05 09:35 PM
Help with Array Declarations Mark \(InWales\)[_19_] Excel Programming 4 December 20th 04 06:39 AM
Constants & Declarations for National Language Support Raul[_4_] Excel Programming 2 April 2nd 04 10:42 PM
Capitalization in Declarations Phil Hageman[_3_] Excel Programming 16 December 24th 03 11:01 PM
Strange variable declarations Steven Revell Excel Programming 1 August 19th 03 02:19 PM


All times are GMT +1. The time now is 11:00 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"