ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Function to add different values (https://www.excelbanter.com/excel-worksheet-functions/86446-function-add-different-values.html)

Douglas

Function to add different values
 
I need one function that adds values that are not equal.

Like this:
3
3
3
4
4
5
5

I need a formula that will go to add value 3+4+5.
Only different numbers between itself.
Which are my options?

Peo Sjoblom

Function to add different values
 
One way

=SUMPRODUCT(--(A1:A10<""),--(1/COUNTIF(A1:A10,A1:A10&"")),A1:A10)

with your data in A1:A10


--

Regards,

Peo Sjoblom

http://nwexcelsolutions.com


"Douglas" wrote in message
...
I need one function that adds values that are not equal.

Like this:
3
3
3
4
4
5
5

I need a formula that will go to add value 3+4+5.
Only different numbers between itself.
Which are my options?




Bernard Liengme

Function to add different values
 
Two possible ways - both assume cells are sorted.

Simple method with helper column
Assume cells are A1:A7
In B1 enter = A1
In B2 enter =IF(A2=A1,0,A2)
Copy down to B7
Find SUM(B1:B7)

User-defined function:
Function unique(myrange)
Dim mycount As Integer
Dim j As Integer
mycount = myrange.Count
unique = myrange(1)
For j = 2 To mycount
If myrange(j) < myrange(j - 1) Then
unique = unique + myrange(j)
End If
Next j
End Function

Use with =UNIQUE(A1:A7)

--
Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email

"Douglas" wrote in message
...
I need one function that adds values that are not equal.

Like this:
3
3
3
4
4
5
5

I need a formula that will go to add value 3+4+5.
Only different numbers between itself.
Which are my options?





All times are GMT +1. The time now is 02:31 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com