Sub 数据合并()
ra = [a650].End(xlUp).Row
For r = 1 To ra
If Range("a" & r) <> "" Then
Range("e" & r) = Range("a" & r)
If r < ra Then
rx = Range("a" & r).End(xlDown).Row
Else
For rx = r To 10000
If Range("b" & rx) = "" Then Exit For
Next rx
End If
For rz = r To rx - 1
Range("f" & r) = Range("f" & r) & “ ” & Range("b" & rz)
Next rz
End If
Next r
End Sub
目前单元格的位置是按照你的例子去做的,你稍微修改一下列号即可应用于你的表格了
追问![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/377adab44aed2e730062cf378e01a18b87d6fa26?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
大神你好,实际效果已经比较接近了,但是我发现一个问题,当A列连续数据超过三个时,B列的数据会一个个往下抓,然后就不对了。
程序我看着头疼,请问能帮我再修改一下吗?
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/e850352ac65c1038884086d9bb119313b07e89eb?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
If Range("b" & rx) = "" Then Exit For
Next rx
这一段改成do-while可以吗?