Ignoring blank cells while locating common text value

Lecum

New Member
Joined
Aug 5, 2018
Messages
2
Dear all,

SOS please...

I am trying to get the most common WORD from my "sold Fish" list but since sometimes I have blank cells the formula keeps giving me n/a

Can anyone help me a provide me with a proper formula?



[TABLE="class: grid, width: 500, align: center"]
<tbody>[TR]
[TD]cod [/TD]
[TD]cod [/TD]
[TD]cod [/TD]
[TD]monkfish[/TD]
[TD] [/TD]
[TD]cod [/TD]
[TD]cod [/TD]
[TD]#n/a[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Code:
Sub FindFrequency()
'Update 20140326
Dim Rng As Range
Dim WorkRng As Range
Set dic = CreateObject("scripting.dictionary")
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
xMax = 0
xOutValue = ""
For Each Rng In WorkRng
    xValue = Rng.Value
    If xValue <> "" Then
        dic(xValue) = dic(xValue) + 1
        xCount = dic(xValue)
        If xCount > xMax Then
            xMax = xCount
            xOutValue = xValue
        End If
    End If
Next
MsgBox "The most common value is: " & xOutValue & " Appeared " & xMax & " Times"
End Sub

It's not my code, I found this on extendoffice.com !

You can modify the output to a cell.
Instead of using this:

Code:
MsgBox "The most common value is: " & xOutValue & " Appeared " & xMax & " Times"

try this for example:

Code:
Range("I1").Value = xOutValue
 
Upvote 0
With your sample data in A1:G1
Here are two related approaches:
This one is an ARRAY FORMULA, completed by holding down CTRL and SHIFT when you press ENTER, instead of just pressing ENTER:
Code:
H1: =INDEX(A1:G1,MATCH(MAX(COUNTIF(A1:G1,A1:G1&"")),COUNTIF(A1:G1,A1:G1&""),0))
This one is a regular formula (no C+S+E necessary):
Code:
H1: =INDEX(A1:G1,MATCH(MAX(INDEX(COUNTIF(A1:G1,A1:G1&""),0)),INDEX(COUNTIF(A1:G1,A1:G1&""),0),0))

Is that something you can work with?
 
Upvote 0
Dear Ron,

The formula it worked perfectly. I really thank you very much for your time and your help.

Thank you

David
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,254
Members
452,624
Latest member
gregg777

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