PC Review


Reply
Thread Tools Rate Thread

Compile error using array

 
 
tmarsh7407
Guest
Posts: n/a
 
      25th Apr 2008
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 With Quote
 
 
 
 
Tim Williams
Guest
Posts: n/a
 
      25th Apr 2008
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" <(E-Mail Removed)> wrote in message
news:4AD89FB0-DE3D-4955-B6CD-(E-Mail Removed)...
> 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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: compile error: expected array. Bob Quintal Microsoft Access Forms 2 28th Jun 2010 12:09 AM
Compile Error:Expected Array Fatima CN Microsoft Excel Programming 1 15th Oct 2009 03:20 AM
Compile Error: Expected Array BEEJAY Microsoft Excel Programming 7 8th Dec 2008 08:23 PM
compile error - expected an array =?Utf-8?B?Sm9obg==?= Microsoft Excel Programming 8 21st Sep 2006 08:04 PM
Compile error help byte array AMP Microsoft C# .NET 12 11th Sep 2006 07:12 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:12 PM.