0

我在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

. . . .

我需要提取“-”和“X”之间的数字,或者整个部分,像这样:-1X; -1.25X;-1.5X;-1.75X 等等。

我该怎么做?

4

2 回答 2

1

如果您尝试从中获取数据的单元格位于 cell 中A1,则此公式将执行此操作:

=MID(A1,FIND("-",A1),FIND("X",A1,FIND("-",A1))-FIND("-",A1)+1)
于 2013-02-01T14:22:39.193 回答
0

这应该有效:

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
于 2013-02-01T14:25:06.180 回答