我有很多很长的字符串,如: 062706440633064A062F0020063106230641062A0020062706440645062D062A06310645002006460648062F002006270639064406270645064306450020062806270646062A0647062706210020062706440627063506440627062D002006390644064900200633064A06270631062A064306450020062C064A06280020062C063106270646062F0634064A063106480643064A0020064A0631062C0649002006270644062D063606480631002006440633062A06440627064506470627002006480634064306310627000D000A062706440645062A062D062F06470020064406440633064A062706310627062A0020002D00200641063106390020062706440646062E064A0644
我想在每四位数之后添加%u
以使其成为正确的Unicode。字符串有不同的大小。
任何人都可以帮我使用Excel功能吗?
答案 0 :(得分:1)
试试这个小 UDF():
Public Function StringFixer(inpt As String) As String
Dim i As Long, j As Long
i = Len(inpt) - 3
For j = 1 To i Step 4
StringFixer = StringFixer & "%u" & Mid(inpt, j, 4)
Next j
StringFixer = Mid(StringFixer, 3) & "%u"
End Function
A1 中的数据,在 A2 中输入:
=StringFixer(A1)
你的例子:
修改#1 强>
要将分隔符放在每个四个字符集的开头而不是 每四个字符集后,请使用此版本:
Public Function StringFixer(inpt As String) As String
Dim i As Long, j As Long
i = Len(inpt) - 3
For j = 1 To i Step 4
StringFixer = StringFixer & "%u" & Mid(inpt, j, 4)
Next j
End Function