Share via

Macro Code For "Last Row"

Anonymous
2016-10-21T18:44:26+00:00

Hello,

My Macro looks like the following:

Selection.AutoFill Destination:=Range("Q2:Q5258")

    Range("Q2:Q5258").Select

This is great as long as I don't go beyond row 5258.

I have a new file and the macro stopped at row 5258.

What can I change this so there will never be a limit on row or column?

Thanks!

P.S.

I just recording the macro  hitting the botton right corner of the cell and double clicking when I was done. Not sure what happened.

Any advice or direction would be greatly appreciated!

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

3 answers

Sort by: Most helpful
  1. Anonymous
    2016-10-21T19:38:52+00:00

    I looked at this page earlier today, but could not figure how to get it to work.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2016-10-21T19:25:15+00:00

    If you don't want to hard code the end row then you must have a column

    to reference for the end row.

    I will assume that Column P is a reference column

    and there is a value in Q2 to be copied down

    Dim Lrow As Long

    Lrow = Cells(Rows.Count, "P").End(xlUp).Row

    ActiveSheet.Range("Q2").Select

    Selection.AutoFill Destination:=Range("Q2:Q" & Lrow)

    This will copy Q2 down as far as there is data in column P

    Gord

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2016-10-21T19:17:40+00:00

    Was this answer helpful?

    0 comments No comments