• Macro to go to end of the row

    Author
    Topic
    #463890

    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

    Viewing 0 reply threads
    Author
    Replies
    • #1185629

      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”

    Viewing 0 reply threads
    Reply To: Macro to go to end of the row

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: