[英]Extract all text before, left of, the last number in a string
I need to removed all text to the left of the final number in my strings. 我需要删除字符串中最后一个数字左侧的所有文本。 Oddly, I can seem to find everything, but this.
奇怪的是,我似乎可以找到所有东西,但是这个。 Here are examples of what I need.
以下是我需要的示例。
Source: 资源:
Result Needed: 需要的结果:
Excel-Extract-Text-Left-of-Final-Number-in-String.jpg Excel的提取物-文字-左的决赛用户号码中,String.jpg
A UDF (aka User Defined Function ) is best for custom parsing string of indeterminate length and structure. UDF(又名用户定义函数 )最适合用于不确定长度和结构的自定义解析字符串。 Paste the following into a module code sheet in the VBE.
将以下内容粘贴到VBE中的模块代码表中。
Function udf_Last_Number_and_Unit(rng As Range)
Dim tmp As String, v As Long, w As Long, vBITs As Variant
vBITs = Split(rng.Value2, Chr(32))
tmp = Join(vBITs, Chr(32))
For v = LBound(vBITs) To UBound(vBITs)
If IsNumeric(vBITs(v)) Then
tmp = vbNullString
For w = v To UBound(vBITs)
tmp = Join(Array(tmp, vBITs(w)), Chr(32))
Next w
End If
Next v
udf_Last_Number_and_Unit = Trim(tmp)
End Function
Use like any native worksheet function. 像任何本地工作表函数一样使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.