title: VBA for Excel: Copy values of one row to another with a unique Identifier
body: <p>I have a large data set with a field (Column A) with two values, Parent and Child. There are parents connected to children with unique identifiers (Column B). Parents have Dates, but their respective children don't (Column C) and Parents and their respective children have different statutes (Column D).</p>
  <p>I need find the parents with the Dates (C) and copy those dates (and the status [D]) of the Parents to their respective Children. Then, delete the Parent rows with dates and Parent and Children without dates, only leaving the data with the Children that have dates and all the information copied from their parents.</p>
  <p>This is what I have (Assume Row with Columns A, B, C,and D names is the Header row):</p>
  <p><a href="https://i.stack.imgur.com/L727C.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/L727C.png" alt="See This Table" /></a></p>
  <p>This is the result I need:</p>
  <p><a href="https://i.stack.imgur.com/pqBdh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pqBdh.png" alt="See Results" /></a></p>
  <p>Keep in mind that not all Parents have Dates or Children, but all children have a parent. Parent can also have at most two Children.</p>
  <p>Cannot simply change the name from Parent to Child, there is other data associated with children that the Parent does not have. <strong>The Children with Dates (and other data from parents) must be the ending result.</strong></p>
  <p>Here is the code I got so far (This is part of a longer code that I have yet to work out). It doesn't have any errors but the logic seems to be off. Not sure if I'm missing something.</p>
  <pre><code>Dim lastentry as Integer
  Dim x as Long
  Dim y as Range
  
  lastentry=UsedRange.Rows(UsedRange.Rows.Count).Row
  x=1
  
      '---Searches through first column for parents with dates, column 3. Then, sets values of parent to the child.---'
  
  Do While Cells(x, 1).Value = &quot;Parent&quot; And IsDate(Cells(x, 3).Value) = True
      For Each y in Range(&quot;A2:A&quot; &amp; lastentry).Cells               '&lt;---Starts on A2 to bypass Header row---'
          If y.Value = &quot;Child&quot; And Range(&quot;B&quot; &amp; y.Row).Value = Cells(x, 2).Value Then
              Range(&quot;C&quot; &amp; y.Row).Value = Cells(x, 3).Value
              Range(&quot;D&quot; &amp; y.Row).Value = Cells(x, 4).Value
              '--- Need to add more Columns here: E, F, G and so on, but not all Columns---&quot;
          End if
      Next y
  Loop
  
      '---Deletes all Parent rows and Children with no dates.---'
  
  For Each y in Range(&quot;A2:A&quot; &amp; lastentry).Cells
      If y.Value = &quot;Parent&quot;
          y.EntireRow.Delete
      End If
  Next y
  
  For Each y in Range(&quot;C2:C&quot; &amp; lastentry).Cells
      If y.Value= &quot;&quot;
          y.EntireRow.Delete
      End If
  Next y
  </code></pre>