Get the value between the brackets

后端 未结 4 1783
感情败类
感情败类 2021-01-12 05:02

I have a column with some stuff that looks like the following string: V2397(+60)

How do I get the value between the brackets? In this case the +60

4条回答
  •  无人及你
    2021-01-12 05:45

    VBA code:

    cellValue = "V2397(+60)"
    openingParen = instr(cellValue, "(")
    closingParen = instr(cellValue, ")")
    enclosedValue = mid(cellValue, openingParen+1, closingParen-openingParen-1)
    

    Obviously cellValue should be read from the cell.

    Alternatively, if cell A1 has one of these values, then the following formula can be used to extrcat the enclosed value to a different cell:

    =Mid(A1, Find("(", A1)+1, Find(")",A1)-Find("(",A1)-1)
    

提交回复
热议问题