title: excel vba- extract text between 2 characters
body: <p>If i had this column:</p>
  
  <pre><code>ColA
  -----
  NUMBER(8,3)
  NUMBER(20)
  </code></pre>
  
  <p>I need a VBA function that would go (note these start and end string would only ever appear once in a cell):</p>
  
  <p>extract_val(cell,start_str,end_str)</p>
  
  <p>ie. extract_val(A1,"(",")") and give the results:</p>
  
  <pre><code>8,3
  20
  </code></pre>
  
  <p>I only need to use this function within other vba code not by putting it as a formula on the sheet.</p>
  
  <p>UPDATE (thanks to the answer, i settled on:)</p>
  
  <pre><code>---------------------------
  Public Function extract_value(str As String) As String
  Dim openPos As Integer
  Dim closePos As Integer
  Dim midBit As String
   On Error Resume Next
  openPos = InStr(str, "(")
   On Error Resume Next
  closePos = InStr(str, ")")
   On Error Resume Next
  midBit = mid(str, openPos + 1, closePos - openPos - 1)
  If openPos &lt;&gt; 0 And Len(midBit) &gt; 0 Then
  extract_value = midBit
  Else
  extract_value = "F"
  End If
  End Function
  
  Public Sub test_value()
  MsgBox extract_value("NUMBER(9)")
  End Sub
  </code></pre>