Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Compile error using array

Can anyone tell me what I'm doing wrong? I have an array in my main Sub
defined as follows:

Dim ActyPrev(1000) As Single

I even have a For Next loop to initialize each single variable in the
array to 0

When I use it inside a For ... Next loop in another subroutine, with the
integor variable Enumr8 as the loop counter, as follows:

ActiveCell.Formula = ActyPrev(Enumr8)

I get a message saying "Compile error: sub or function not defined"
highlighting "ActyPrev".

I'm using Excel 2003 but think we will be moving to 2007 soon. Any
suggestions would be welcome.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Compile error using array

If your array is defined within a procedure it will not be visible to other
procedures unless you pass it in as a parameter.
http://www.ozgrid.com/VBA/variable-scope-lifetime.htm
Tim

"tmarsh7407" wrote in message
...
Can anyone tell me what I'm doing wrong? I have an array in my main Sub
defined as follows:

Dim ActyPrev(1000) As Single

I even have a For Next loop to initialize each single variable in the
array to 0

When I use it inside a For ... Next loop in another subroutine, with the
integor variable Enumr8 as the loop counter, as follows:

ActiveCell.Formula = ActyPrev(Enumr8)

I get a message saying "Compile error: sub or function not defined"
highlighting "ActyPrev".

I'm using Excel 2003 but think we will be moving to 2007 soon. Any
suggestions would be welcome.




Reply
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
Excel VBA Compile Error when dimensioning jagged array EngPhys_Bate Excel Programming 2 August 22nd 07 03:28 AM
compile error - expected an array John Excel Programming 8 September 21st 06 08:04 PM
formula array gives compile error R..VENKATARAMAN Excel Programming 2 June 6th 06 01:20 PM
VBAProject name compile error, not defined at compile time Matthew Dodds Excel Programming 1 December 13th 05 07:17 PM
Help: Compile error: type mismatch: array or user defined type expected lvcha.gouqizi Excel Programming 1 October 31st 05 08:20 PM


All times are GMT +1. The time now is 06:05 PM.

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

About Us

"It's about Microsoft Excel"