仔细对比了,发现你的代码很简单,而且上边一位给的代码在运行时碰到单元格为空就出错,你的代码就能兼容这种,但是我在改编时有个新问题,就是如果原始数据从c列扩展到了e列,(即增加了1列,)此时我改编代码后,第一排的数据始终还是字母ab等等,没法转换为相应的字符,请你帮我看下,我的代码改编后是Sub test()
Dim arr, i, j, brr
arr = [c1].CurrentRegion: brr = [h2:i7]
For i = 3 To UBound(arr, 1)
For j = 1 To UBound(brr, 1)
arr(i, 1) = Replace(arr(i, 1), brr(j, 1), "、" & brr(j, 2))
arr(i, 2) = Replace(arr(i, 2), brr(j, 1), "、" & brr(j, 2))
arr(i, 3) = Replace(arr(i, 3), brr(j, 1), "、" & brr(j, 2))
Next
arr(i, 1) = Replace(arr(i, 1), "(、", "(")
arr(i, 2) = Replace(arr(i, 2), "(、", "(")
arr(i, 3) = Replace(arr(i, 3), "(、", "(")
Next
[k1].Resize(UBound(arr, 1), 3) = arr
End Sub
错在哪里呢,附件见下图
|