title: Parse substring from text
body: <p>I am writing a macro that converts a list of names that are in an LDAP format to First, Last (region).</p>
  
  <p>For those who do not know what LDAP looks like, it is below:</p>
  
  <blockquote>
    <p>CN=John Smith (region),OU=Legal,DC=example,DC=comand</p>
  </blockquote>
  
  <p>In Excel VBA, I do not appear to be able to use string.substring(start, end). A search on Google seems to reveal that Mid(string, start, end) is the best option.</p>
  
  <p>The problem is this: In Mid, the integer for end is the distance from start, not the actual index location of the character. This means that different name sizes will have different ending locations and I cannot use index of ")" to find the end of the region.  Since all of the names start with CN=, I can find the end of the first substring properly, but I cannot find ")" properly because names are different lengths.  </p>
  
  <p>I have some code below:</p>
  
  <pre><code>mgrSub1 = Mid(mgrVal, InStr(1, mgrVal, "=") + 1, InStr(1, mgrVal, "\") - 4)
  mgrSub2 = Mid(mgrVal, InStr(1, mgrVal, ","), InStr(1, mgrVal, ")") - 10)
  manager = mgrSub1 &amp; mgrSub2
  </code></pre>
  
  <p>Is there a way to use a set end point instead of an end point that is so many values away from the start?  </p>