您好,如果字符长度比较小,字库不多,那么用MID函数分解A1单元格,用VLOOKUP函数来检索查找字库,用&连接符链接每个查找到的字符,例如=VLOOKUP(MID(A1,1,1),Sheet2!A:B,2,false) & "," & VLOOKUP(MID(A1,2,1),Sheet2!A:B,2,false) & "," & VLOOKUP(MID(A1,3,1),Sheet2!A:B,2,false)
其中Sheet2!A:B为字库文件
如果字数比较多的话,可以使用VBA编程,如:
代码如下,此时改变单元格A1的数值,在B1自动会计算出您要的答案。
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = 1 And Target.Column = 1 Then
m = Len(Cells(1, 1))
Dim a() As String '建立两个动态数组为字库
Dim b() As String
For k = 1 To m '使用
for循环将单元格内字符分组
If Cells(1, 1) <> "" Then
ReDim Preserve a(k - 1) '确定动态数组下标
a(k - 1) = Mid(Cells(1, 1), k, 1) '分解A1单元格,每个字符为字库中每一个字
End If
Next
ReDim Preserve b(k - 2) '确定动态数组下标
For i = 0 To k - 2
Select Case a(i) '用Select赋值字库中每一个字
Case "我"
b(i) = "1,2,3"
Case "爱"
b(i) = "4,5,6"
Case "你"
b(i) = "7,8,9"
End Select
If c <> "" Then
c = c & "," & b(i)
Else
c = b(i)
End If
Next
Cells(1, 2) = c
End If
End Sub本回答被提问者采纳