Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Brooklyn, New York, USA
    Posts
    200
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Hey all,
    Can anyone tell me how to build the part of a macro that will jump to the end of a particular row (end-arrow key)that has changing ranges? I recorded a macro with keystrokes, but it only jumped to the end of the exact range in the original set of data. For example, if the data set on which I record the macro has a range of A1 to C1, when I run the macro on a range of A1 to D1, the cursor still only jumps to C1, even though all the cells are filled.

    thanks!

    Naomi

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    To go to the end of the current row:

    Selection.End(xlToRight).Select

    or to go to the end of a row that you specify in code:

    Dim lngRow As Long
    lngRow = 37
    Cells(lngRow, 1).End(xlToRight).Select

    BTW in many situations it isn't necessary to select a cell in code. For example, if you want to set the value of the last cell in row 5 to "Finished", you could use

    Range("A5").End(xlToRight).Select
    ActiveCell = "Finished"

    but it's more efficient to use

    Range("A5").End(xlToRight) = "Finished"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •