ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Down One Row (https://www.excelbanter.com/excel-programming/396090-down-one-row.html)

Mike H.

Down One Row
 
Usually I can navigate a spreadsheet by getting the row # and going down 1 row:
x=activecell.row
x=x+1
cells(x,1).select
So if I was on row 25 now I am on row 26. But what if the data is filtered
and row 26 is not in the filter. I want to go down 1 row but how can I know
which row that is?

Ron Coderre

Down One Row
 
Try something like this:

Sub DownToNextVisibleCell()
Dim lngCtr As Long
Dim lngCurrCol As Long

lngCurrCol = ActiveCell.Column

For lngCtr = ActiveCell.Row + 1 To Rows.Count
With Cells(RowIndex:=lngCtr, ColumnIndex:=lngCurrCol)
If .EntireRow.Hidden = False Then
.Select
Exit For
End If
End With
Next lngCtr
End Sub


Is that something you can work with?
***********
Regards,
Ron

XL2003, WinXP


"Mike H." wrote:

Usually I can navigate a spreadsheet by getting the row # and going down 1 row:
x=activecell.row
x=x+1
cells(x,1).select
So if I was on row 25 now I am on row 26. But what if the data is filtered
and row 26 is not in the filter. I want to go down 1 row but how can I know
which row that is?


Mike H.

Down One Row
 
That works perfectly. Thanks a lot.


Bob Phillips

Down One Row
 
What do you mean by how can you know? You won't see it in Excel, because you
have selected a non-visible row, but it is still active, and

?activecell.Row


returns that row in the immediate window.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Mike H." wrote in message
...
Usually I can navigate a spreadsheet by getting the row # and going down 1
row:
x=activecell.row
x=x+1
cells(x,1).select
So if I was on row 25 now I am on row 26. But what if the data is
filtered
and row 26 is not in the filter. I want to go down 1 row but how can I
know
which row that is?




Ron Coderre

Down One Row
 
I'm glad I could help, Mike........Thanks for the feedback.

***********
Regards,
Ron

XL2003, WinXP


"Mike H." wrote:

That works perfectly. Thanks a lot.



All times are GMT +1. The time now is 11:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com