View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Define name, count rows problem.

Hi Sommer,

Based on a suugestion by Dana DeLouis, try:

Sub Tester03()

Dim i As Long

i = Intersect(Range("Data").EntireRow, _
Columns(1)).Cells.Count

MsgBox i

End Sub


---
Regards,
Norman



"sommer" wrote in message
...
I would like to count the number of rows in a named range that contains
multiple areas on the same worksheet. To setup the range, I held the
Control
key down while selecting the three different areas and then selected
InsertNameDefine to establish the "data" range. The following code
yields
10 rows and not the expected 21. It appears the code only considers the
first
part of the named range and not the entire string.
Any help would be appreciated.
Thanks
Sommer

Names in workbook:
data

Refers to:
=Sheet1!$A$3:$M$12,Sheet1!$A$25:$M$30,Sheet1!$A$40 :$M$44

Macro code:
Set CheckArea = Range("data")
NumberOfRows = CheckArea.Rows.Count