Results 1 to 6 of 6

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
    11,011

    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,212

    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

  6. #6
    New Member
    Join Date
    Nov 2014
    Location
    Schertz, TX
    Posts
    1

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

    I think I have a similar question but am not sure. I have created a macro that copies fields to a separate tab/table in Excel and linked the macro to a command button. Each time the processer uses types in the data on the specified fields and clicks the button, I want that data copied to the next table and cleared out of the entry fields. The reason I am saying that my problem is similar is I want each time they process the macro for excel to past all the fields one row lower than the previous so the data isn't overwritten but added to the listing. Any help you can provide is greatly appreciated. If you have any questions, please let me know. Thank you.

    Jeremy

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