我在 Excel 单元格中有以下文本:
$abcd.$efghijk.$lmn.$op.$qrst.
我只需要使用 Excel 公式在 Excel 单元格中使用以下格式的上述文本:
abcd$abcd.efghijk$efghijk.lmn$lmn.op$op.qrst$qrst.
以下是我将根据讨论提出的建议。
在通用模块中,插入以下代码。
Public Function RepeatCustom(strInput As String) As String
Dim varInput As Variant
Dim i As Long
If Len(strInput) = 0 Then
RepeatCustom = ""
Else
varInput = Split(strInput, ".")
For i = LBound(varInput) To UBound(varInput)
RepeatCustom = RepeatCustom & " " & Mid(varInput(i), 2, Len(varInput(i))) & varInput(i)
Next
RepeatCustom = Replace(Trim(RepeatCustom), " ", ".") & "."
End If
End Function
然后假设包含原始数据的单元格是A2,你可以使用上面的UDF:
=重复自定义(A2)
请注意,代码是最少的,并且基于发布的示例。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句