在excel中提取两个字符之间的字符串

时间:2015-02-12 16:32:27

标签: excel

我有以下字符串

- Pri."Priority Description"

如何解析PriPriority Description?在excel中,我试试这个=MID(A1,FIND("\",A1)+1,FIND("\",A1,4)-FIND("\",A1)-1)

1 个答案:

答案 0 :(得分:0)

首先输入以下 UDF

Public Function GrabString(s1 As String, s2 As String, s3 As String) As String
    Dim L2 As Long, L2x As Long, sx As String
    L2 = Len(s2)
    L2x = InStr(s1, s2) + L2
    sx = Mid(s1, L2x)
    GrabString = Left(sx, InStr(1, sx, s3) - 1)
End Function

UDF 将返回由其他两个字符串包含的子字符串。
然后 A1中的数据 输入:

=GrabString(A1,"- ",".")

并在 C1 中输入:

=GrabString(A1,"""","""")

显示:

enter image description here