VBA Autofill Down According to Adjacent Column Using Last Cell
<p>What I am trying to do here is write a code that will autofill down in Column A to the last row of data, according to Column B, using the last cell with data in Column A as the range for autofill. For instance Column A is &quot;Name&quot; and B is &quot;Date&quot;. Column B has 6 dates, while Column A has a different &quot;Name&quot; every few rows down. Here is what I have so far:</p>
<pre><code>Sub test()

    Dim lastRow As Long
    lastRow = Range(&quot;B&quot; &amp; Rows.Count).End(xlUp).Row
    Range(&quot;A2&quot;).AutoFill Destination:=Range(&quot;A2:A&quot; &amp; lastRow)

End Sub
</code></pre>
<p>Here is my problem:</p>
<p>I would like to run the script and have it select the last filled cell in A (A4 for instance) and autofill down to the last row with data in column B.</p>
<p>My problem is it keeps selecting &quot;A2&quot; instead of the last cell in A (&quot;A4&quot; in this example) to autofill and fills all of column A with &quot;A2&quot;, to the right distance none the less.</p>