making single array from non-contiguous ranges

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!
 
B

Bob Phillips

How about this

Function JoinArrays(rng1, rng2) As Variant

JoinArrays = Union(rng1, rng2)
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top