Count rows in named range
Function RowsInNamedRange(NamedRange As Range) As Long
RowsInNamedRange = NamedRange.Rows.Count
End Function
--
__________________________________
HTH
Bob
"John" wrote in message
...
I'm not a VBA expert, and this is a very simple function...
I'm trying to create a function that will count the number of rows in
a named range. The function will be used in a formula in the workbook.
This is what I have:
-------------------------------
Function RowsInNamedRange(NamedRange As Range) As Integer
RowsInNamedRange = Range(NamedRange).Rows.Count
End Function
-------------------------------
When I test via immediate window using:
? RowsInNamedRange "rngNamedRange1"
Where "rngNamedRange1" is a named range. I get a type mismatch error.
I know this is a simple fix...but just haven't figured it out yet. Any
pointers??
|