title: VBA: How to Pull Mid String 2 Character State From Address?
body: <p>I am looking for the best way to go about manipulating this string: We need to extract a state from the invoice line description field of my Excel. Here is an example of the type of line I need to extract the state from:</p>
  
  <pre><code>Managment Blvd.Philadelphia.PA.19103
  Management EXECUTIVE CTJACKSONVILLE.FL.32216-4041
  </code></pre>
  
  <p>So as you can see, the state code is immediately after the zip code from the right side. Here is what I am thinking:</p>
  
  <pre><code>IF(isnumeric(Right(mystring,5)) 
  
  Then 
  MyString = Right(mystring,8)
  MyString =Left(mystring,2)
  
  End If
  </code></pre>
  
  <p>Would that give me the 2 characters for the state? Or is there a much better way to do this? Maybe even add some checks by adding a table of state abbreviations to compare the characters to make sure they match a state.</p>
  
  <p>Currently however, I do not know what to do for Zip codes that include the +4 like in the 2nd example. Any help is appreciated! </p>