View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
[email protected] FortisChet@gmail.com is offline
external usenet poster
 
Posts: 8
Default Is the array empty?

On Mar 14, 6:02 pm, JP wrote:
I found this on another board, does it help?

If IsError(Application.Match("*", (myArray), 0)) Then
MsgBox "Empty array"
Else
MsgBox "Something, somewhere"
End If

--JP

On Mar 14, 6:58 pm, "
wrote:

Hi


I am using a macro to load an array with data from excel. This is time
series data. As I loop through all the years and months, there are
some months that don't exist in a specific year (eg for 2005, the data
starts from April, whereas my array loops over all months).


So when I look up this array in the local variables, each element of
the array shows up as EMPTY.


this causes a problem cos at the end of all this, I'm trying to do :


worksheetfunction.average(array)


and it fails when I the array is empty.


Is there anyway to determine if the array is empty, cos then I can use
an if statement to circumvent.


I've tried using lbound, ubound, isempty etc etc...nothing seems to be
working.


Suggestions are deeply appreciated.


Thanks
Chet



WOW! Yeah it seems to be working, i'll run a few loops to test it. I
guess the " * " is the generic for any non empty element right? so it
tests if the array has ANYTHING non empty and then gives the
corresponding msg.

Thanks a ton for this one.

Truly
Chet