title: Excel VBA to copy rows if cell empty and delete if value deleted
body: <p>I have a vba code to copy the row (A to G) if column D is not blank to a different worksheet in the workbook. It works just fine. However, I need it to delete the row from the spreadsheet that it is copied to if the value is removed from the column.</p>
  
  <p>So the user will put in a value in a cell in column D. That row is copied to a different spreadsheet. But if they change their mind and delete that value, I need the row removed from the other spreadsheet.</p>
  
  <p>Here's what I have:</p>
  
  <pre><code>Private Sub Worksheet_Change(ByVal Target As Range)
  
      Dim sIn As Worksheet, sOut As Worksheet, rIn As Range, rOut As Range
      Dim inputdata() As Variant
      Dim tmpArr(1 To 7) As Variant
      Dim i As Long, outcount As Long
  
     Set sIn = Sheets("Supply Request")
     Set sOut = Sheets("Order")
     Set rIn = sIn.UsedRange
     Set rOut = sOut.Range("A5:G5")
  
     inputdata = rIn.Value
     outcount = 0
  
     For i = 1 To UBound(inputdata, 1)
         If inputdata(i, 4) &lt;&gt; "" Then
             outcount = outcount + 1
             tmpArr(1) = inputdata(i, 1)
             tmpArr(2) = inputdata(i, 2)
             tmpArr(3) = inputdata(i, 3)
             tmpArr(4) = inputdata(i, 4)
             tmpArr(5) = inputdata(i, 5)
             tmpArr(6) = inputdata(i, 6)
             tmpArr(7) = inputdata(i, 7)
             rOut.Offset(outcount - 1, 0).Value = tmpArr
             Erase tmpArr
         End If
     Next i
     Erase inputdata
  End Sub
  </code></pre>