Find Common Text in 3 Rows

lafata2000

New Member
Joined
Sep 29, 2021
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hi all... I need to be able to get the most common text in a string out of 3 rows..... Example below:

Column 1Column 2Column 3Formula Needed
ARM KIT,,FR SUSP RHCONTROL ARMSuspension Control ArmArm
SensorOIL LEVEL SENDEREngine Oil Level SensorSensor
TS WATER PUMPWater Pump 1 EA CQWPSEngine Water PumpWater Pump

I have tried the below and it is does not return any text..... any thoughts?
=INDEX(B2:D2,MODE(MATCH(B2:D2,B2:D2,0)))
=INDEX(B2:D2,MODE(IF(ISTEXT(B2:D2),MATCH(B2:D2,B2:D2,0))))
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
How about this.
Make sure your data has a header. The loop starts at row 2.

VBA Code:
Sub jec()

 Dim dict As Object
 Dim jv, ar, sp, it As Variant
 Dim i As Long
 Dim c00 As String

 Set dict = CreateObject("scripting.dictionary")
 dict.CompareMode = 1
 jv = Sheets(1).Cells(1, 1).CurrentRegion.Resize(, 5)
 
 For i = 2 To UBound(jv)
    ar = Split(Replace(Join(Array(jv(i, 1), jv(i, 2), jv(i, 3))), ",,", " "))
    With Cells(1, 100).Resize(UBound(ar) + 1)
       .ClearContents
       .Value = Application.Transpose(ar)
        sp = Filter(Application.Transpose(Evaluate(Replace("if(max(countif(@@,@@))=countif(@@,@@),@@,""~"")", "@@", .Address))), "~", False)
    End With
  
    For Each it In sp
      c00 = dict(it)
    Next
 
    jv(i, 5) = Join(dict.keys, ", ")
    dict.RemoveAll
 Next

 Sheets(1).Cells(1, 1).CurrentRegion.Resize(, 5) = jv
End Sub
 
Upvote 0
How about this.
Make sure your data has a header. The loop starts at row 2.

VBA Code:
Sub jec()

 Dim dict As Object
 Dim jv, ar, sp, it As Variant
 Dim i As Long
 Dim c00 As String

 Set dict = CreateObject("scripting.dictionary")
 dict.CompareMode = 1
 jv = Sheets(1).Cells(1, 1).CurrentRegion.Resize(, 5)
 
 For i = 2 To UBound(jv)
    ar = Split(Replace(Join(Array(jv(i, 1), jv(i, 2), jv(i, 3))), ",,", " "))
    With Cells(1, 100).Resize(UBound(ar) + 1)
       .ClearContents
       .Value = Application.Transpose(ar)
        sp = Filter(Application.Transpose(Evaluate(Replace("if(max(countif(@@,@@))=countif(@@,@@),@@,""~"")", "@@", .Address))), "~", False)
    End With
 
    For Each it In sp
      c00 = dict(it)
    Next
 
    jv(i, 5) = Join(dict.keys, ", ")
    dict.RemoveAll
 Next

 Sheets(1).Cells(1, 1).CurrentRegion.Resize(, 5) = jv
End Sub
You are so awesome! Thank you so much! Worked like a charm!
 
Upvote 0
You're welcome!:)
Hi JEC, question for you....... it seems as though the VBA code is not comparing Column 1 with 2 and 3, is it possible to do all 3?

Column 1Column 2Column 3Formula
LATCHLOCK ACTUATORLIFTGATE ACTUATORACTUATOR
LATCHLock Actuator 1 PC DORMALIFTGATE ACTUATORActuator
LOCKINTGR LATCH ACTUATORLIFTGATE ACTUATORACTUATOR
LOCKINTGR LATCH ACTUATOR 1 PC DORMLIFTGATE ACTUATORACTUATOR
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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