View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Paul Paul is offline
external usenet poster
 
Posts: 25
Default Check for subscript out of range

Hi all,

In a function I want to fill an array with values. This function goes
through a given column on a sheet (say coumn B) and stores the values in the
array, skipping all the duplicates. Every time the function is called the
array is redimmed so it starts with an 'empty' array and then fills it.

Now in the next column (column C) i also have some values which also have to
be put into the array, again skipping the duplicates. Depending on if column
B was empty or not, the array has already got some values in it. When
proceeding to column C how can i check if the array is already populated by
at least 1 value?

I cannot use Ubound, but I can also not check for the error (subscript is
out of range) by using IsError, or something else.


code:
dim boolArrayHasNoValues as Boolean

boolArrayHasNoValues = IsError(UBound(NoDuplicates)) <<<<<<supscript is out
of range

''if NoDuplicates is not yet redim / rather if NoDuplicates has no values
yet then

For iTemp = 1 To AllCells.Cells.Count
'get first value in selection of cells, and stop this part of
the function
'this is to make sure that there are no empty values in the
array
If Not AllCells.Cells(iTemp) = "" Then
ReDim NoDupes(1)
NoDupes(1) = AllCells.Cells(iTemp)
Exit For
End If
Next iTemp
''End If