Consulting

Results 1 to 3 of 3

Thread: Sleeper: Selecting visible cells.

  1. #1
    VBAX Mentor Sir Babydum GBE's Avatar
    Joined
    Mar 2005
    Location
    Cardiff, UK
    Posts
    499
    Location

    Sleeper: Selecting visible cells.

    Hi



    I'm creating a very sexy little worksheet and I would like some advice please.

    I simply need to know 1) how to move down 1 cell on a filtered list. Because if I use my down-arrow or return keys to navigate manually, the next visible cell is selected. But a macro seems just to select the next cel - regrdless of wher it is hidden in the filter or not.

    And 2) How do I say in code language;
    Check whether the cell I've just landed on is merged, and if it is not - perform this action. But if it is, skip this cell and try the next, and so on. Finally, if after skipping so many cells the macro gets to myRow number, then display a warning "Run out of options" and quit the code.
    Suggestions will be much appreciated.

    babydum
    Have a profound problem? Need a ridiculous solution? Post a question in Babydum's forum

  2. #2
    VBAX Master Killian's Avatar
    Joined
    Nov 2004
    Location
    London
    Posts
    1,132
    Location
    Well I'm all for sexy worksheets...
    Here's a couple of virtually identical routines - one checking for a hidden (filtered) row and the other checking for merged cells both with a row limit.

    Sub One()
    Dim c As Range
        Const myRow As Long = 20
    Set c = ActiveCell
    Do
            c.Offset(1, 0).Activate
            Set c = ActiveCell
        Loop Until ActiveSheet.Rows(c.Row).Hidden = False Or c.Row > myRow
    If c.Row > myRow Then MsgBox "Run out of options"
    End Sub
    
    
    Sub Two()
    Dim c As Range
        Const myRow As Long = 20
    Set c = ActiveCell
    Do
            c.Offset(1, 0).Activate
            Set c = ActiveCell
        Loop Until Not c.MergeCells Or c.Row > myRow
    If c.Row > myRow Then MsgBox "Run out of options"
    End Sub
    K :-)

  3. #3
    VBAX Mentor sheeeng's Avatar
    Joined
    May 2005
    Location
    Kuala Lumpur
    Posts
    392
    Location
    Quote Originally Posted by Babydum
    Hi



    I'm creating a very sexy little worksheet and I would like some advice please.

    I simply need to know 1) how to move down 1 cell on a filtered list. Because if I use my down-arrow or return keys to navigate manually, the next visible cell is selected. But a macro seems just to select the next cel - regrdless of wher it is hidden in the filter or not.



    And 2) How do I say in code language;
    Check whether the cell I've just landed on is merged, and if it is not - perform this action. But if it is, skip this cell and try the next, and so on. Finally, if after skipping so many cells the macro gets to myRow number, then display a warning "Run out of options" and quit the code.


    Suggestions will be much appreciated.


    babydum
    Wow...I hope to see the solution for that...for I don't know...Sorry

Posting Permissions

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