Reputation: 967
I have a situation like this in excel 2007:
.15X.04-1.25X.625-SD+str
.15X.04-1.25X1.25-SD
.15X.04-1.5X1.25-SD
.15X.04-1.75X1.75-SC
.15X.04-1X.625-SD+str
.15X.04-2.25X2.25-SC
.15X.04-2.5X2.5-SC
.15X.04-2.75X2.75-SC
.15X.04-2X1.75-SC
.15X.04-3X3-SC
.15X.06-1.25X.625-SD+str
. . . .
I need to extract the number between "-" and "X", OR the whole part ,like this: -1X; -1.25X; -1.5X; -1.75X and so on .
how can i do it?
Upvotes: 0
Views: 156
Reputation: 28059
This should work:
Private Function GetValue(ByVal cellLocation As String) As String
Dim txt As String
txt = Application.Range(cellLocation).text
Dim split As String
split = split(txt, "-")(0)
Dim result As String
result = split(partOne, "X")(0)
GetValue = result
End Function
Upvotes: 0
Reputation: 19544
If the cell you're trying to get the data from were in cell A1
, this formula would do it:
=MID(A1,FIND("-",A1),FIND("X",A1,FIND("-",A1))-FIND("-",A1)+1)
Upvotes: 1