VBA to autofill from relative location

A

AlexJarvis

If I need to autofill column B from the last cell that has data in it to the
same row as the last cell of column A that has data in it, how do I set the
destination for the autofill correctly?



I have tried a lot of ways that seemed obvious and all of them return errors.


Here is where I am stuck:

Selection.AutoFill Destination:=Range(B[this number is the active cell, or
the one I just put a value in in column B]:B[this number should be the same
as the last cell that has a value in it in column A])
 
J

Jacob Skaria

Try

Dim lngRow As Long

lngRow = Cells(Rows.Count, "A").End(xlUp).Row
Selection.AutoFill Destination:=Range("B" & ActiveCell.Row & ":B" & lngRow)
 
A

AlexJarvis

Good deal, thank you!

I was forgetting to put a "&" in there...

-A

Jacob Skaria said:
Try

Dim lngRow As Long

lngRow = Cells(Rows.Count, "A").End(xlUp).Row
Selection.AutoFill Destination:=Range("B" & ActiveCell.Row & ":B" & lngRow)


--
Jacob (MVP - Excel)


AlexJarvis said:
If I need to autofill column B from the last cell that has data in it to the
same row as the last cell of column A that has data in it, how do I set the
destination for the autofill correctly?



I have tried a lot of ways that seemed obvious and all of them return errors.


Here is where I am stuck:

Selection.AutoFill Destination:=Range(B[this number is the active cell, or
the one I just put a value in in column B]:B[this number should be the same
as the last cell that has a value in it in column A])
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top