excel 第一列满足查找条件的对应第二列的字符串合并

如:
单位 发票号码
A 000182
B 000183
C 000184
A 000185
B 000187

得到
A 000182,000185
B 000183,000187
C 000184

这个……先将第一列排序(如果允许的话),然后用公式

=MID(SUBSTITUTE(PHONETIC(OFFSET($A$1,MATCH(D1,$A$1:$A$5,)-1,,COUNTIF($A$1:$A$5,D1),2)),D1,","),3,99)

下拉填充。

如图所示

温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-05-12
可以试试 vba

Sub a()
Application.ScreenUpdating = False
Dim dic As Object, i, j, arr, r
Set dic = CreateObject("Scripting.Dictionary")
arr = Range("a1:a" & Range("a65536").End(xlUp).Row)
For i = 1 To UBound(arr)
r = dic(arr(i, 1))
Next
Range("c1").Resize(dic.Count, 1) = Application.Transpose(dic.Keys)
Columns("d:d").Select
Selection.NumberFormatLocal = "@"
For j = 1 To Range("c65536").End(xlUp).Row
For i = 1 To UBound(arr)
If Cells(i, 1).Value = Cells(j, 3).Value Then
If Cells(j, 4).Value = "" Then
Cells(j, 4).Value = Cells(i, 2).Value
Else
Cells(j, 4).Value = Cells(j, 4).Value & "," & Cells(i, 2).Value
End If
End If
Next i
Next j
Application.ScreenUpdating = True
End Sub
最终结果 在 CD 列
第2个回答  2011-05-13
假设条件为大于3的数,那么公式如下:

是数组公式,写完公式按ctrl+shift+enter确定公式。
其它条件把IF(A1:A100>3,A1:A100,"")替换就行。
想要降序,就把small换成large。

不明白的直接hi我,或者把文件发到我的邮箱,我帮你做
[email protected]
追问

大哥 上面没显示公式呢?

第3个回答  2011-05-12
应该没有什么现成的函数能解决的吧?

可以用VBA自定义函数来完成,需要的话Hi我
相似回答