title: Excel: Scanning column with multiple conditions
body: <p>I just started off as a new programmer and I'm trying to create Vba code to scan the following data in Excel. </p>
  
  <p>Let's assume </p>
  
  <pre><code>Apple = 123456
  
  Apple Juice = 987654
  
  Pear = 234567
  Pear Juice = 987654
  
  Orange = 345678
  
  Orange Juice = 987654
  </code></pre>
  
  <p>The codes for each item will be given but what I want is to write a program to detect the specific codes and assigning it the names (apple, apple juice etc.). If "123456" appears first, then the cell below it will be assigned "Apple Juice". If "234567" appears first, then it will be assigned "Pear Juice". It is challenging for me as Juice category shares the same "987654" unlike the Fruits which has a unique FruitNo assigned to it. </p>
  
  <p>However, I am having difficulty writing the codes for the scanning of above cells. I have tried using the ActiveCellOffset but it doesn't seem to be functioning to the way I want it.</p>
  
  <p><a href="https://i.stack.imgur.com/GsaT8.png" rel="nofollow noreferrer">The following codes are what I have tried so far. 
  </a></p>
  
  <p><a href="https://i.stack.imgur.com/QzqZ4.png" rel="nofollow noreferrer">And this is the outcome I would like to have. The red letters are the names that the program is suppose to come up with. 
  </a></p>