+ Reply to Thread
Results 1 to 3 of 3

Thread: VBA - With Range Selected, how to back up one row?

  1. #1
    Forum Contributor
    Join Date
    12-20-2011
    Location
    United States, Ohio
    MS-Off Ver
    Excel 2010
    Posts
    242

    VBA - With Range Selected, how to back up one row?

    Please excuse me for I am very new at this. I dont know the code lanuage on how to do it.

    My goal is to automate with a macro, these stroke combinations. (the macro recorder is not working the way I need it to).

    If I was using keyboard short cuts =
    1) Select H117 on Sheet7
    2) ctrl + shirt + down arrow
    3) shift + up arrow

    I currently have (and I know its WRONG)...
    Sub Macro6()
    '
    ' Macro6 Macro
    '
    
    '
        Range("H117").Select
        Range(Selection, Selection.End(xlDown)).Select
        With Selection
            .Range(ActiveCell, ActiveCell.Offset(-1, 0)).Select
        End With
    End Sub
    Any help is greatly appreciated. Thanks in advance.
    Last edited by clemsoncooz; 12-30-2011 at 11:34 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    12-28-2011
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    276

    Re: VBA - With Range Selected, how to back up one row?

    So you want to select everything bar the last row of data?

    Range("H117",Cells(117,"H").End(xlDown).Offset(-1)).Select
    Note that you rarely ever need to Select anything to work with it - it makes your code slower and less efficient than it could be. But for learning I think it's fine.

  3. #3
    Forum Contributor
    Join Date
    12-20-2011
    Location
    United States, Ohio
    MS-Off Ver
    Excel 2010
    Posts
    242

    Re: VBA - With Range Selected, how to back up one row?

    yup! wonderful! Thank you!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0