Results 1 to 5 of 5

Macro; Move 1 cell down (left, right..)

This is a discussion on Macro; Move 1 cell down (left, right..) within the Excel Questions forums, part of the Question Forums category; Hi there ! Simply need a code snippet - how to move 1 cell down... As opposed to this: Selection.End(xlDown).Select ...

  1. #1
    New Member
    Join Date
    Jul 2002
    Posts
    33

    Default Macro; Move 1 cell down (left, right..)

    Hi there !

    Simply need a code snippet - how to move 1 cell down...

    As opposed to this:

    Selection.End(xlDown).Select

    which moves you to the bottom of the Range.


    Must work on filtered ranges !
    ( So, no solutions like:
    a = ActiveCell.Column
    b = ActiveCell.Row
    Cells(b+1,a).Select

    please...)


    Bye !

  2. #2
    Board Regular
    Join Date
    Jun 2003
    Posts
    56

    Default Re: Macro; Move 1 cell down (left, right..)

    Move 1 cell right:
    Selection.Offset(0, 1).Select

    Move 1 cell down:
    Selection.Offset(1, 0).Select

  3. #3
    New Member
    Join Date
    Jul 2002
    Posts
    33

    Default Re: Macro; Move 1 cell down (left, right..)

    PureFire:

    quick, simple - great !

    Thanks a lot !

    Keep on burning...

  4. #4
    MrExcel MVP Tom Urtis's Avatar
    Join Date
    Feb 2002
    Location
    San Francisco, California USA
    Posts
    10,984

    Default Re: Macro; Move 1 cell down (left, right..)

    Just an FYI, you said you want it to work in a filtered range, which PureFire's code will not do - - it will select the next row whether filtered or not. One way to select the next filtered (visible) row:

    Sub Test1()
    Dim x As Long, y As Long
    x = ActiveCell.Row
    y = ActiveCell.Column
    Do
    x = x + 1
    Loop Until Cells(x, y).EntireRow.Hidden = False
    Cells(x, y).Select
    End Sub


    Unfortunately, the code looks like something you say you don't want, but it does what you say you want it to do.

  5. #5
    MrExcel MVP
    Moderator
    SydneyGeek's Avatar
    Join Date
    Aug 2003
    Location
    Sydney, Australia
    Posts
    12,175

    Default Re: Macro; Move 1 cell down (left, right..)

    What do you want to do once you have jumped to the next cell?

    This may not quite be what you are after, but it could get you thinking...

    Code:
    Sub GrabFilteredRange()
    
    Dim MyRange As Range
    Dim c As Range
    
        ActiveCell.CurrentRegion.Select
        Set MyRange = Selection.SpecialCells(xlCellTypeVisible)
        
        For Each c In MyRange
          Debug.Print c.Value
        Next c
    End Sub
    This goes in sequence along each row in your range, visiting only the visible cells, and writes them out to the debug window. Presumably you could further restrict the range of movement by intersecting with Column A

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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


DMCA.com