ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Cell selection with hidden rows (https://www.excelbanter.com/excel-programming/278351-cell-selection-hidden-rows.html)

Andrew[_24_]

Cell selection with hidden rows
 
I have a spreadsheet that has hidden rows (hidden by using AutoFilter).

I wish to write a macro in which I need to select a cell on the visible row
below the current cell. For example if the currently selected cell is on
row 2 and rows 3-6 are hidden I wish to select the cell on row 7.

If the rows were not hidden I could use
ActiveCell.Offset(1,0).Range("A1").Select

How can I achieve what I want with an unknown variable number of hidden rows
between two visible rows?





DomThePom[_2_]

Cell selection with hidden rows
 
Use RowHeight property of range object as follows:

****************code starts*************

Sub GoToNextVisibleCellDown()
Dim cell As Range
Set cell = ActiveCell
Do
Set cell = cell.Offset(1, 0)
Loop While cell.RowHeight = 0
cell.Select
Set cell = Nothing
End Sub

****************code ends*************



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/


Andrew[_24_]

Cell selection with hidden rows
 
DomThePom wrote:
Use RowHeight property of range object as follows:

****************code starts*************

Sub GoToNextVisibleCellDown()
Dim cell As Range
Set cell = ActiveCell
Do
Set cell = cell.Offset(1, 0)
Loop While cell.RowHeight = 0
cell.Select
Set cell = Nothing
End Sub

****************code ends*************



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from
http://www.ExcelForum.com/


Excellent, thank you. I'm a bit of a novice as you might have guessed!




All times are GMT +1. The time now is 01:52 AM.

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