Does anyone know if there's a union operator in Excel 2010?
I have tried ;
and ,
, neither of them seems to work. For instance, =E2:E3;E4:E6
, =E2:E3,E4:E6
, {=E2:E3;E4:E6}
and {=E2:E3,E4:E6}
always return an error.
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.
Sign up to join this communityDoes anyone know if there's a union operator in Excel 2010?
I have tried ;
and ,
, neither of them seems to work. For instance, =E2:E3;E4:E6
, =E2:E3,E4:E6
, {=E2:E3;E4:E6}
and {=E2:E3,E4:E6}
always return an error.
Excel's 'union' operator has always been the comma* (e.g. A1:A9,F2:G4
) while its intersect operator is a single space. It's not that it doesn't work, it's just that not all Excel functions can accept this reference method.
Here are some that do:
SUM()
COUNT()
COUNTA()
SMALL()
LARGE()
MIN()
MAX()
AVERAGE()
However, when you think about it, the ,
does not exactly do mathematical union, but rather set addition. For example, =COUNT(A1,A1,A1)
returns 3
. If it were truly a union operator, this formula would return 1
.
**Some Euro-versions use the semicolon (;
) instead, depending on the computer's regional settings.*
(Further reading: Microsoft Office: Calculation operators and precedence)
SMALL((A1,B1,F1),2)
- if you don't use the internal parentheses that doesn't work - You can also use this in RANK and FREQUENCY functions
– barry houdini
Mar 23 '15 at 14:27
SUM
, AVERAGE
etc. functions allow up to 255
arguments I doubt this is as helpful as it might have been once.....but another use of the union is to allow more discontiguous cells to be used e.g. =SUM(A1,B1,F1)
is using 3 references while =SUM((A1,B1,F1))
is only 1
– barry houdini
Mar 23 '15 at 14:30
=(A2,C8,C10) A2
will give the intersection of A2
and (A1,C8,C10)
just to give an insane example. Note that in general you'll want to avoid this
– dtech
Jun 23 '15 at 11:51
LINEST
and this answer doesn't work.
– Maciej Piechotka
Oct 25 '17 at 21:20
If you want to sum values, you can write this:
=SUM(I3:M3;I4:M4;I5:M5)
If you want to merge texts, you can write this (or use your mouse as @soandos says):
=CONCATENATE(A1;B1;C1;D1)
It looks like you want to write . But, as I know, it is not possible (gives error).=CONCATENATE(A1:D1)
The question is not too clear, but for now, it seems like you have to merge texts. So for instance – as per your example if you have to union E2, E3, E4, E5, E6 you can write a formula like:
=CONCATENATE(E2,E3,E4,E5,E6)
I tried it myself: You have to individually describe cells. ":" This is not working for me too in Concatenate. So you should try as explained above.
Else, mmdemirbas's answer perfectly explains the SUM
formula.
In short the answer is NO.
However, for some functions you can use the following workaround,
=COUNTA(B1:B3,A2:C2)-COUNTA(B1:B3 A2:C2)
Note that the ranges have one cell in common (ie intersecting). The "," is used by some functions to allow multiple range to be provided as parameter. This is not a union as this will include the intersection cell twice. It will be COUNTED TWICE. So, by subtracting the intersection you get the correct answer.
This technique should work with the following:
SUM()
COUNT()
COUNTA()
It won't work with:
SMALL()
LARGE()
The formula can be modified to work with:
AVERAGE()
It is never required with MAX and MIN
!
It's a real pain that it works like this and that there is no UNION operator.
In VBA you can write a function that create a proper union:
see here for info http://www.cpearson.com/excel/BetterUnion.aspx
ie
Function ProperUnion(ParamArray Ranges() As Variant) As Range
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' ProperUnion
' This provides Union functionality without duplicating
' cells when ranges overlap. Requires the Union2 function.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim ResR As Range
Dim N As Long
Dim R As Range
If Not Ranges(LBound(Ranges)) Is Nothing Then
Set ResR = Ranges(LBound(Ranges))
End If
For N = LBound(Ranges) + 1 To UBound(Ranges)
If Not Ranges(N) Is Nothing Then
For Each R In Ranges(N).Cells
If Application.Intersect(ResR, R) Is Nothing Then
Set ResR = Union2(ResR, R)
End If
Next R
End If
Next N
Set ProperUnion = ResR
End Function