title: find nearest cell with a specific value in vba
body: <p>I have to developp a little program in vba (which I don't use very much).</p>
  
  <p>I have a sheet with "parent" lines, and for each parent, I have a list of "child" lines :</p>
  
  <pre><code>line 1 parent
  line 2 childa
  line 3 childb
  line 4
  line 5 parent
  line 6 childc
  line 7 childd
  line 8
  line 9 parent
  line 10 childe
  </code></pre>
  
  <p>I have to export these data in a new file, and be able to tell from each child at which parent he is connected.</p>
  
  <p>To do that I want to develop a macro with the following principe :</p>
  
  <p>For a child, I keep his line number in memory, then I do a findnext on parent until I exceed the line keep in memory. Basically when I am on a child, I want to find the cell of his closest parent starting from the top of the sheet.
  Exemple : I call a function with the input parameter 2, I would like to get in return line 1.
  input : line 7, return : line 5</p>
  
  <p>As I am not very familiar with vba, I am struggling a lot, thanks in advance for your help.</p>