简体   繁体   English

在excel单元格中提取字符串的一部分

[英]Extract part of a string in excel cell

I have an excel spreadsheet in which there is a column containing a specific string. 我有一个excel电子表格,其中有一个包含特定字符串的列。 I need to extract part of that string in another column. 我需要在另一列中提取该字符串的一部分。

The data is as follows: 数据如下:

Column A 
---------------------------------
FIS/SIFT/SBG091241012FIS/SIFT/SBG091241012
FIS/SIFT/SBG091311212FIS/SIFT/SBG09111212
..
...

Is there any formula in excel through which i can extract the last part of string after forward slash (/). excel中是否有任何公式可以通过它来提取正斜杠(/)后的字符串的最后部分。 In the above example these are: 在上面的例子中,这些是:

SBG091241012
SBG09111212

Please note that the last part of string after slash (/) is variable length so we may not be able to use the =RIGHT function in excel. 请注意斜杠(/)后面的字符串的最后一部分是可变长度的,因此我们可能无法在excel中使用= RIGHT函数。

Use this function .. 使用此功能..

Function GetTail(r As Range) As String
Dim s As String

s = r.Value
GetTail = Mid(s, InStrRev(s, "/") + 1)
End Function

Though the above answer is perfect. 虽然上面的答案是完美的。 But in case you like Right function for any reason: 但是如果您因任何原因喜欢Right功能:

Right(str, Len(str) - InStrRev(str, "/", -1, vbTextCompare)) 右(str,Len(str) - InStrRev(str,“/”, - 1,vbTextCompare))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM