|
楼主 |
发表于 2021-2-17 22:51
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub sawd()
arr = [a1].CurrentRegion
ReDim brr(1 To UBound(arr), 1 To 1)
For x = 1 To UBound(brr)
brr(x, 1) = PinYin(Cells(x, 1))
Next
[b1].Resize(UBound(brr), 1) = brr
a = Array("sai", "yi", "de", "ban")
b = Array("赛", "依", "德", "班")
For i = 0 To 2
[b:b].Replace a(i), b(i)
Next
Set reg = CreateObject("vbscript.regexp")
With reg
.Global = True
.Pattern = "[^\u4e00-\u9fa5]+" '\u4e00-\u9fa5是用来判断是不是中文的一个条件
For x = 1 To UBound(brr)
Cells(x, 2) = Mid(.Replace(Cells(x, 2).Value, ""), 1, 1)
Next
.Pattern = ".*?([\d一二三四五六七八九十壹贰叁肆伍陆柒捌玖拾]+)|.+"
For x = 1 To UBound(brr)
Cells(x, 3) = .Replace(Cells(x, 1), "$1")
Next
crr = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)
drr = Array("一", "二", "三", "四", "五", "六", "七", "八", "九")
For x = 0 To 8
[c:c].Replace drr(x), crr(x)
Next
For x = 1 To UBound(brr)
If Cells(x, 1) Like "*[a-zA-Z]*" Then
Cells(x, 2) = Cells(x, 1)
Else
Cells(x, 2) = Cells(x, 2) & Cells(x, 3)
End If
Next
End With
[c1].Resize(UBound(brr), 1).ClearContents
End Sub
我不太懂最后加一个循环要在哪里加呢?或者你标红告诉我如果要加别的字要在那几处修改,我试一下能不能自己修改,谢谢
|
|