![]() |
Create Range of Visible Rows only
I would like to create a range containing only the visible rows in columns
A:N. I can filter the list and then create a range but it selects all the hidden rows as well. Is there a way to restrict the range to just the visible rows? H |
Create Range of Visible Rows only
Assume the range is A1:C25
Sub testVis() Dim rng As Range, c As Range Set rng = ActiveSheet.Range("A1:C25") For Each c In rng.SpecialCells(xlCellTypeVisible) If c.Row.Hidden = True Then MsgBox "Not Working" Else MsgBox "Working" End If Next End Sub You should get Working only when the macro runs. "Humphrey" wrote in message ... I would like to create a range containing only the visible rows in columns A:N. I can filter the list and then create a range but it selects all the hidden rows as well. Is there a way to restrict the range to just the visible rows? H |
Create Range of Visible Rows only
Sorry Humphrey, left out a key word. Use this.
Sub testVis() Dim rng As Range, c As Range Set rng = ActiveSheet.Range("A1:C25") For Each c In rng.SpecialCells(xlCellTypeVisible) If Rows(c.Row).Hidden = True Then MsgBox "Not Working" Else MsgBox "Working" End If Next End Sub "Humphrey" wrote in message ... I would like to create a range containing only the visible rows in columns A:N. I can filter the list and then create a range but it selects all the hidden rows as well. Is there a way to restrict the range to just the visible rows? H |
All times are GMT +1. The time now is 04:42 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com