View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JP[_4_] JP[_4_] is offline
external usenet poster
 
Posts: 897
Default Is the array empty?

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