title: Rules to extract the right path
body: <p>I need some help to fix this code I've wrote.</p>
  
  <pre><code>Perc1 = ThisWorkbook.Path
  Slash1 = InStrRev(Perc1, "\")
  PercF = Left(Perc1, Slash1 - 1)
  Slash2 = InStrRev(PercF, "\")
  PercFinale = Left(PercF, Slash2) &amp; "04-OFFERTE_CONTRATTO" &amp; "\"
  </code></pre>
  
  <p>And the values are:</p>
  
  <pre><code>: Perc1 : "E:\DENNIS\01_Progetti\1_TRATTATIVE\IT.18.9462_O. Aeroporto (ROMA)\03-CALCOLO\02-XLS\Edificio E1" : Variant/String
  : Slash1 : 102 : Variant/Long
  : PercF : "E:\DENNIS\01_Progetti\1_TRATTATIVE\IT.18.9462_O. Aeroporto (ROMA)\03-CALCOLO\02-XLS" : Variant/String
  : Slash2 : 95 : Variant/Long
  : PercFinale : "E:\DENNIS\01_Progetti\1_TRATTATIVE\IT.18.9462_O. Aeroporto (ROMA)\03-CALCOLO\04-OFFERTE_CONTRATTO\" : String
  </code></pre>
  
  <p>This ends in an error because 03-CALCOLO and 04-OFFERTE_CONTRATTO are in the same folder.</p>
  
  <p>I want that Percf ends always after "...\03-CALCOLO" even when I've subfolders in 02-XLS (as in this case).</p>
  
  <p>Can you give me an advice please?</p>
  
  <p>Thank you very much!</p>
  
  <p>Dennis</p>