问题
I would like to get a distinct list of column J if cell in H of same row equals "No Company".
I tried =IFERROR(INDEX($J$2:$J$10, MATCH(0, COUNTIF($K$1:K2, $J$2:$J$10&"") + IF(ISTEXT($H$2:$H$10)="No company",1,0), 0)), ""))
also tried =IFERROR(INDEX(J$2:J$400, SMALL(IF((H$2:H$400=No company)>1)), ROW(j$2:j$400)-ROW(j$2)+1), ROWS(j$2:j2)), "") changing some of the fields but no luck
Desired result + Try
回答1:
Create a new function: open VBA Editor (alt + F11), add new module, insert code:
Function JoinAll(ByRef range As range, ByVal delimiter As String)
For Each c In range.Cells
If InStr(JoinAll, c.Value) = 0 Then
JoinAll = JoinAll + c.Value + delimiter
End If
Next
JoinAll = Left(JoinAll, Len(JoinAll) - Len(delimiter))
End Function
use formula like this:
=JoinAll(J2:J10, ", ")
来源:https://stackoverflow.com/questions/40166146/get-distinct-list-index-if-adjacent-value-equals-a-specific-text-in-excel