- Sub qs()
- Dim ar, i, dic, arr
- Set dic = CreateObject("scripting.dictionary")
- ar = [{0,"零";1,"壹";2,"贰";3,"叁";4,"肆";5,"伍";6,"陆";7,"柒";8,"捌";9,"玖"}]
- For i = 1 To UBound(ar)
- dic(ar(i, 1)) = ar(i, 2)
- Next
- r = Sheet1.Cells(Rows.Count, 1).End(xlUp).Row
- arr = Sheet1.Range("a2").Resize(r - 1, 3).Value
- For i = 1 To UBound(arr)
- s = arr(i, 1)
- t = Val(Left(arr(i, 2), 1))
- arr(i, 1) = Replace(s, arr(i, 2), "")
- arr(i, 2) = VBA.Replace(arr(i, 2), t, dic(t))
- arr(i, 3) = arr(i, 1) & arr(i, 2)
- Next
- Sheet1.Range("c2").Resize(UBound(arr), 1) = Application.Index(arr, 0, 3)
- End Sub
复制代码 |