#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default How To:

I have a data entry form that has Next, Previous buttons which navigate through the worksheet, my problem is that if the users leave a filter I only want to navigate through the visible rows, like using the cursor, the problem is that my code navigates through the hidden rows, so my questions is how to I make my code only navigate through the visible rows.

Application.Cells(Application.ActiveCell.Row + 1, Application.ActiveCell.column).Activate


TIA
KM
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default How To:

This works but is there a better way

Do
Application.Cells(Application.ActiveCell.Row + 1, Application.ActiveCell.column).Activate
Loop Until Not Application.ActiveSheet.Rows(Application.ActiveCel l.Row).Hidden

"Kevin McCartney" wrote:

I have a data entry form that has Next, Previous buttons which navigate through the worksheet, my problem is that if the users leave a filter I only want to navigate through the visible rows, like using the cursor, the problem is that my code navigates through the hidden rows, so my questions is how to I make my code only navigate through the visible rows.

Application.Cells(Application.ActiveCell.Row + 1, Application.ActiveCell.column).Activate


TIA
KM

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default How To:

Hi Kevin,

Adapting some autofilter code posted by Tom Ogilvy, perhaps this would help:

Sub SelectNextVisible()
Dim Rng As Range, Rng1 As Range
Dim iCol As Long
iCol = ActiveCell.Column
Set Rng = ActiveCell.CurrentRegion '<<< Amend to suit
Set Rng = Intersect(Rng, Columns(iCol))
Set Rng = Range(ActiveCell.Offset(1, 0), Rng(Rng.Count))

On Error Resume Next
Set Rng1 = Rng.SpecialCells(xlVisible)
On Error GoTo 0
If Not Rng1 Is Nothing Then
Rng1(1).Select
End If
End Sub


---
Regards,
Norman



"Kevin McCartney" wrote in
message ...
This works but is there a better way

Do
Application.Cells(Application.ActiveCell.Row + 1,

Application.ActiveCell.column).Activate
Loop Until Not

Application.ActiveSheet.Rows(Application.ActiveCel l.Row).Hidden

"Kevin McCartney" wrote:

I have a data entry form that has Next, Previous buttons which navigate

through the worksheet, my problem is that if the users leave a filter I only
want to navigate through the visible rows, like using the cursor, the
problem is that my code navigates through the hidden rows, so my questions
is how to I make my code only navigate through the visible rows.

Application.Cells(Application.ActiveCell.Row + 1,

Application.ActiveCell.column).Activate


TIA
KM



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How To:

That is probably as easy as any. Any other method would take a bit more
code I think.

You can do it without selecting or activating:

Dim rng as Range
set rng = ActiveCell
Do
set rng = ActiveCell.Offset(1,0)
Loop until rng.EntireRow.Hidden = False or rng.row = 50
if rng.EntireRow.Hidden = False then
rng.Select
else
msgbox "No more visible data"
End if


--
Regards,
Tom Ogilvy


"Kevin McCartney" wrote in
message ...
This works but is there a better way

Do
Application.Cells(Application.ActiveCell.Row + 1,

Application.ActiveCell.column).Activate
Loop Until Not

Application.ActiveSheet.Rows(Application.ActiveCel l.Row).Hidden

"Kevin McCartney" wrote:

I have a data entry form that has Next, Previous buttons which navigate

through the worksheet, my problem is that if the users leave a filter I only
want to navigate through the visible rows, like using the cursor, the
problem is that my code navigates through the hidden rows, so my questions
is how to I make my code only navigate through the visible rows.

Application.Cells(Application.ActiveCell.Row + 1,

Application.ActiveCell.column).Activate


TIA
KM



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 10:00 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"