title: VBA Last Row for Specific Text Value
body: <pre><code>Sub SeperateRowSub()
  
  Dim FirstRowPFW As Integer
  Dim LastRowPFW As Integer
  
  FirstRowPFW = Range("B:B").Find(what:="Planning/Fieldwork", after:=Range("B6")).Row
  LastRowPFW = Range("B:B").Find(what:="Planning/Fieldwork", after:=Range("B6"), searchdirection:=xlPrevious).Row
  
  End Sub
  </code></pre>
  
  <p>FirstRowPFW returns the correct row that it starts at.
  Lastrow continues to count the rest of the rows, even those outside of the "planning/fieldwork" criteria. </p>
  
  <p>How can I fix the lastrowpfw variable to only count to the last row for cells containing "Planning/Fieldwork" ?</p>