title: VBA Auto populate depending on value in two separate rows
body: <p>I couldn't find the answer to my question anywhere so here it goes.<br>
  I have a table which contains order IDs and Unit numbers. Order IDs have numerous Unit numbers and I'm only interested in Order IDs that have Unit numbers that are different from zero, even if they have some Unit numbers that are zero.<br>
  It looks something like this:<br>
      <code>Order ID   Unit Number
        XD23            0
        XD23            0
        XD23            1
        XD23            0
        CF25            0
        CF25            0
        CF25            2
        LQ29            0
        LQ29            0
        LQ29            0</code></p>
  
  <p>And would like to get this kind of output:</p>
  
  <pre><code>Order ID   Unit Number
    XD23            1
    XD23            1
    XD23            1
    XD23            1
    CF25            1
    CF25            1
    CF25            1
    LQ29            0
    LQ29            0
    LQ29            0
  </code></pre>
  
  <p>So every row of Order ID should have a value of 1 if anywhere within that Order ID an Unit number different from zero exists.<br>
  I tried creating a loop with if conditions but I'm pretty new to VBA so it wasn't successful.<br>
  Maybe I need a solution that checks former, current and next Order ID to evaluate if they differ so they could restart checking 0 &amp; 1.<br>
  Thank you very much!</p>
  
  <p>Edit: Code that I have -  I tried to test this out for a single Order ID  </p>
  
  <pre><code>Sub Test1()
  
  Dim rngID As Range
  Dim rngUnit As Range
  Dim dblMax As Double
  Dim OrderID As OrderID
  Dim OrderID As New OrderID
  
  OrderID.ID = "CBR516038001"
  
  
   'Set range from which to determine largest value
   Set rngID = Sheet1.Range("I2:I1000000")
  Set rngUnit = Sheet1.Range("AQ2:AQ1000000")
  
  
  'Worksheet function MAX returns the largest value in a range
  For Each OrderID.ID In rngID.Rows
      dblMax = OrderID.Value
  Next
  
   For Each OrderID.ID In rngID.Rows
       rngUnit.Rows = dblMax
   Next
  
  
   End Sub
  </code></pre>