Dealing with ties in the Mode Function

Stephen_IV

Well-known Member
Joined
Mar 17, 2003
Messages
1,168
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
I encountered a problem that I had with the Mode function. If I am trying to pull out the mode from a list of numbers and there is a tie, How do I pull out both numbers. For instance

2
3
4
1
7
8
5
7
8

My results should be 7 and 8. Can some one help.
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
If there is a tie the Mode() function will return the first value it encountered in this case 7. If the numbers were

9
7
7
7
9
9

It would return 9.

If you want multiple values you would probably need to make your own function.
 
Upvote 0
Hi Stephen:

I recall we dealt recently with some questios regarding 1st mode, and 2nd mode, etc. Anyway, let us have a look at ...
Book1
ABCDE
127
2388
34
41
57
68
75
87
98
Sheet1


Cell C1 hoses the 1st mode, and cells C2 and D2, the light Turquoise and light yellow colored cells house two alternate formulations for the 2nd mode.

Is this what you are looking for?
 
Upvote 0
Just to add a bit. Those are both array formulas you when you enter them press (control + shift + enter) and not just enter to make them work.
 
Upvote 0
When you have a notion of what (multiple) results you are expecting, you can use countif() to to return the count of each value you are expecting. In a long sequence of entries this may be not be feasible.

couple that with a column of: small(
#VALUE!
 
Upvote 0
HI

A UDF. Note that it will return the #VALUE! error message if there is no mode.

Tony

Function moder(x As Range)
Dim modes As New Collection

For Each ce In x
If WorksheetFunction.CountIf(x, ce) = WorksheetFunction.CountIf(x, WorksheetFunction.Mode(x)) Then
On Error Resume Next
modes.Add Item:=ce, key:=Str(ce)
End If
Next

For i = 1 To modes.Count
moder = moder & "," & modes(i)
Next i
moder = WorksheetFunction.Substitute(moder, ",", "", 1)
End Function
 
Upvote 0
Thanks Tony and Yogi. Tony thats the approach that I was looking for! Thank you also Yogi for your time as well as nbrcrunch and DRJ
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top