Range Select

  • I am trying to select a range using VBA and have run into run-time error '1004': Method 'Range' of object '_Global' failed.
    If I write the code this way it works fine:

    Code
    Range("A" & lastrow  + 2).Select


    I have lastrow set this way:

    Code
    lastrow = Worksheets("Detail Inventory").Range("B5").End(xlDown).Row


    But if I expand the range by writing the code this way:

    Code
    Range("A & lastrow + 2:U47").Select


    I get the run-time error.


    Anybody have an idea what I am doing wrong?


    Thanks

  • You need to use:

    Code
    Range("A" & lastrow + 2 & ":U47").Select

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • You're welcome.

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!