试试看- Function PinYin(Rng As Range) Dim dic As Object, i%, j%, arr, str$, irow%
- PinYin = ""
- Set dic = CreateObject("scripting.dictionary")
- irow = Sheets("hanziku").Cells(Rows.Count, "A").End(xlUp).Row
- arr = Sheets("hanziku").Range("a1:b" & irow)
- For i = 1 To UBound(arr)
- For j = 1 To Len(arr(i, 1))
- str = Mid(arr(i, 1), j, 1)
- If Not dic.exists(str) Then
- dic(str) = arr(i, 2)
- End If
- Next
- Next
- For j = 1 To Len(Rng.Value)
- str = Mid(Rng.Value, j, 1)
- If dic.exists(str) Then
- PinYin = PinYin & WorksheetFunction.Proper(dic(str))
- Else
- PinYin = PinYin & LCase(str)
- End If
- Next
- End Function
复制代码 |