PDA

View Full Version : Sleeper: Selecting visible cells.



Sir Babydum GBE
07-14-2005, 08:07 AM
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

Killian
07-14-2005, 08:47 AM
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

sheeeng
07-15-2005, 08:31 AM
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 :doh: