excel固定数字转固定英文
发布网友
发布时间:2022-05-24 23:28
我来回答
共3个回答
热心网友
时间:2023-11-12 12:48
建议你用宏,数字长短不一样的时候也可以用。
下面是代码:
Sub 宏1()
Columns("C:C").Select
Range("C7").Activate
Selection.Replace What:="0", Replacement:="C", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.Replace What:="1", Replacement:="U", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.Replace What:="2", Replacement:="M", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.Replace What:="3", Replacement:="B", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.Replace What:="4", Replacement:="E", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.Replace What:="5", Replacement:="R", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.Replace What:="6", Replacement:="L", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.Replace What:="7", Replacement:="A", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.Replace What:="8", Replacement:="N", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.Replace What:="9", Replacement:="D", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub
热心网友
时间:2023-11-12 12:48
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(C2,0,"C"),1,"U"),2,"M"),3,"B"),4,"E"),5,"R"),6,"L"),7,"A"),8,"N"),9,"D")追问
报错哦朋友。
追答2003只能用七层以下嵌套,可以用2007以上版本(XLSX格式),使用这个公式。
用2003,可以修改一下公式:(假设C2数据小于等于6位)
=LOOKUP(--MID(C2,1,1),A2:B11)&IF(LEN(C2)<2,"",LOOKUP(--MID(C2,2,1),A2:B11))&IF(LEN(C2)<3,"",LOOKUP(--MID(C2,3,1),A2:B11))&IF(LEN(C2)<4,"",LOOKUP(--MID(C2,4,1),A2:B11))&IF(LEN(C2)<5,"",LOOKUP(--MID(C2,5,1),A2:B11))&IF(LEN(C2)<6,"",LOOKUP(--MID(C2,6,1),A2:B11))
热心网友
时间:2023-11-12 12:49
暂时觉得用自定义函数比较方便,用自带函数略麻烦
Function exchange(aa As Range, bb As Range, cc As Range)
Dim i%, j%, jg As Variant
j = bb.Count
jg = aa.Value
For i = 1 To j
jg = Application.WorksheetFunction.Substitute(jg, bb.Cells(i), cc.Cells(i))
Next
exchange = jg
End Function