+ Reply to Thread
Results 1 to 2 of 2

Navigating Rows Dynamic Range

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    01-30-2011
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    102

    Navigating Rows Dynamic Range

    I have a range "LoopRange"

    I have code to look through each row in the range

    on command button click:

    ActiveCell.Offset(-1, 0).Select
    to move up, and on a separate button:

    ActiveCell.Offset(1, 0).Select
    to move down

    My issue is that I would like that if the last row at the bottom is reached, it will jump back up to the first row, and vice versa.

    Thanks in advance.
    Last edited by ZooTV92; 08-26-2011 at 11:36 PM.

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Navigating Rows Dynamic Range

    ZooTV92,

    Attached is a sample workbook based on the criteria you provided. The bordered section is a named range: "LoopRange". The Up and Down buttons are Form controls that are both assigned to the following macro:
    Sub btn_Click()
        
        If Intersect(ActiveCell, Range("LoopRange")) Is Nothing Then
            Range(Split(Range("LoopRange").Address, ":")(0)).Select
            Exit Sub
        End If
        
        Select Case ActiveSheet.Buttons(Application.Caller).Caption
            Case "Up"
                If ActiveCell.Address = Split(Range("LoopRange").Address, ":")(0) Then
                    Range(Split(Range("LoopRange").Address, ":")(1)).Select
                Else
                    ActiveCell.Offset(-1, 0).Select
                End If
            Case "Down"
                If ActiveCell.Address = Split(Range("LoopRange").Address, ":")(1) Then
                    Range(Split(Range("LoopRange").Address, ":")(0)).Select
                Else
                    ActiveCell.Offset(1, 0).Select
                End If
        End Select
        
    End Sub


    Hope that helps,
    ~tigeravatar
    Attached Files Attached Files

+ 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.6.0 RC 1