Excel中按条件合并字符串
答案:2 悬赏:80 手机版
解决时间 2021-06-01 07:39
- 提问者网友:难遇难求
- 2021-05-31 18:59
A列相同的名称时,把A列相同的只取一个,然后将A相同值的B列字符串合并,看文件
最佳答案
- 五星知识达人网友:等灯
- 2021-05-31 19:28
假设第一个“张三”在单元格A5里。
代码如下:
Sub test()
Dim i, j As Integer
Dim xRng As Range
Range("E5:E999").ClearContents
For i = 5 To Range("A9999").End(xlUp).Row
Set xRng = Range("E5:E999").Find(Range("A" & i), LookAt:=xlWhole)
If xRng Is Nothing Then
Set xRng = Range("E999").End(xlUp).Offset(1, 0)
xRng = Range("A" & i)
xRng.Offset(0, 1) = Range("B" & i)
xRng.Offset(0, 2) = Range("C" & i)
Else
xRng.Offset(0, 2) = xRng.Offset(0, 2) & "/" & Range("C" & i)
End If
Next i
End Sub
代码如下:
Sub test()
Dim i, j As Integer
Dim xRng As Range
Range("E5:E999").ClearContents
For i = 5 To Range("A9999").End(xlUp).Row
Set xRng = Range("E5:E999").Find(Range("A" & i), LookAt:=xlWhole)
If xRng Is Nothing Then
Set xRng = Range("E999").End(xlUp).Offset(1, 0)
xRng = Range("A" & i)
xRng.Offset(0, 1) = Range("B" & i)
xRng.Offset(0, 2) = Range("C" & i)
Else
xRng.Offset(0, 2) = xRng.Offset(0, 2) & "/" & Range("C" & i)
End If
Next i
End Sub
全部回答
- 1楼网友:西风乍起
- 2021-05-31 20:00
=PHONETIC((INDIRECT("r"&MATCH(E1,A:A,0)&"c3:R"&MATCH(E1,A:A,0)-1+COUNTIF(A:A,E1)&"c3",0)))
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯