title: Converting excel formula into VBA macro
body: <p>I have a sheet in excel which has a lookup column for all our internal dial-code definitions.
  (these are in column F &amp;G )  -
  I then have a lookup column where we want to match the dialcodes from our customers to find the closest match.
  The formula does this right now over a series of columns by checking if there is a match, and if not then it strips out the last number and then compares again</p>
  <p>I then compare them to the definitions i am given</p>
  <p>And by removing 1 number at a time - i eventually get to a match on the codes
  <a href="https://i.stack.imgur.com/bcQCn.png" rel="nofollow noreferrer">how the sheet parses to get the match</a>
  <a href="https://i.stack.imgur.com/YDgM3.png" rel="nofollow noreferrer">table of dial-code matches</a></p>
  <p>I have it in an excel formula right now but would like to make it be a VBA function i can call so it runs faster - it would need to compare all of column F and G as the match which is sorted in numerical order</p>
  <pre><code>=IF($A3=&quot;&quot;,&quot;&quot;,IF(AND(F3=&quot;&quot;, CONCATENATE(C3,D3, E3,F3) = &quot;&quot;), IF(ISNA(VLOOKUP(LEFT($B3,MAX(0, LEN($B3) - G$1))+0,Input!$F:$G,1,FALSE))=FALSE,
  VLOOKUP(LEFT($B3,MAX(0, LEN($B3) - G$1))+0,Input!$F:$G,2,FALSE),&quot;&quot;),&quot;&quot;))
  </code></pre>