#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Set RNG

This code works to count hidden rows. But how can I set the range when I call
the function rather than have a spectific range in the code itself.

Function CountHidden()
Dim CellCount As Long
CellCount = 0
Set RNG = Range("a1:a9")
For Each Cell In RNG
If Cell.EntireRow.Hidden Then
CellCount = CellCount + 1
End If
Next Cell
CountHidden = CellCount
End Function
--
Howard
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Set RNG

Howard,

Function CountHidden(ByRef RNG As Excel.Range) As Long
Dim CellCount As Long
Dim rCell As Excel.Range
CellCount = 0
For Each rCell In RNG.Rows
If rCell.Hidden Then
CellCount = CellCount + 1
End If
Next rCell
CountHidden = CellCount
End Function
'--
Sub FeedThatFunction()
Dim x As Long
x = CountHidden(Selection)
MsgBox x & " hidden "
End Sub

--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"Howard"
wrote in message
This code works to count hidden rows. But how can I set the range when I call
the function rather than have a spectific range in the code itself.

Function CountHidden()
Dim CellCount As Long
CellCount = 0
Set RNG = Range("a1:a9")
For Each Cell In RNG
If Cell.EntireRow.Hidden Then
CellCount = CellCount + 1
End If
Next Cell
CountHidden = CellCount
End Function
--
Howard
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Set RNG

Jim,

Thanks very much!
--
Howard


"Jim Cone" wrote:

Howard,

Function CountHidden(ByRef RNG As Excel.Range) As Long
Dim CellCount As Long
Dim rCell As Excel.Range
CellCount = 0
For Each rCell In RNG.Rows
If rCell.Hidden Then
CellCount = CellCount + 1
End If
Next rCell
CountHidden = CellCount
End Function
'--
Sub FeedThatFunction()
Dim x As Long
x = CountHidden(Selection)
MsgBox x & " hidden "
End Sub

--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"Howard"
wrote in message
This code works to count hidden rows. But how can I set the range when I call
the function rather than have a spectific range in the code itself.

Function CountHidden()
Dim CellCount As Long
CellCount = 0
Set RNG = Range("a1:a9")
For Each Cell In RNG
If Cell.EntireRow.Hidden Then
CellCount = CellCount + 1
End If
Next Cell
CountHidden = CellCount
End Function
--
Howard

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 11:03 PM.

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

About Us

"It's about Microsoft Excel"