making single array from non-contiguous ranges

  • Thread starter Thread starter Stonie J
  • Start date Start date
S

Stonie J

The TTEST() function in Excel takes an array for its first argument.
The problem is that the array of data I need to enter is not
contiguous. For example, the values I need are in A2:A15 and A30:A40.
Is there some quick and easy way to combine non-contiguous ranges into
a single array? Something like:

TTEST({A2:A15,A30:A40}, B2:B40, 2, 2)

The simple solution is to move the two ranges together, but that will
cause other problems for me. If need be, we can go into what those
problems are, but first I wanted to see if there was an easier
solution. Could a Simple UDF be written? In a form like:

TTEST(MAKE_ARRAY(A2:A15, A30:A40), B2:B40, 2, 2)

Thanks!
 
How about this

Function JoinArrays(rng1, rng2) As Variant

JoinArrays = Union(rng1, rng2)
End Function
 
Back
Top