Range.End

  • When I use Range.End to select a range nothing is getting selected and the cursor ends up exactly 10,000 rows past the target row. What am I doing wrong? The code is posted below:


    Code
    Dim lRow As Long
    
    
    lRow = Cells(Rows.Count, 1).End(xlUp).Row
    
    
    Range("E1" & lRow).Select
  • That's because your column A has formulas down to A10000 (or are formatted or other).

    Done that, now I'm guessing, I think you should also change your code like this:

    Code
    Dim lRow   As Long
    lRow = Cells(Rows.Count, 1).End(xlUp).Row
    Range("E" & lRow).Select                   '<= changed
  • Hello,


    To be on the safe side ... would recommend two tiny modifications :


    lRow = Cells(Rows.Count, 5).End(xlUp).Row ' to use Column E as your reference


    Range("E" & lRow).Select ' to select the proper row .... removed the 1 from "E1"


    Hope this will help

    :)

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

  • manster_mg please read the Forum Rules to understand how the Forum works and why I have added Code Tags to your post


    All VBA code posted in the forum must be wrapped in code tags, which you omitted, including single-line code snippets.Be sure to use them in future posts.


    How to use code tags

    Note: no apostrophe in the tags, just used for demonstration here.

    ['code]


    your code goes between these tags


    ['/code]


    Or, just highlight all of the code and press the <> in the post menu above button to add the code tags.


    Thanks.


    Also, note this applies to all code snippets including one liners!

Participate now!

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