ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Dynamic Named Range count (https://www.excelbanter.com/excel-programming/318939-dynamic-named-range-count.html)

Matt Jensen

Dynamic Named Range count
 
Howdy
When I do a count of a dyanmic named range I get 1, when I do it for a
static named range I get the correct count of the range.
This is my code:

Private Sub UserForm_Initialize()
Dim DirectorateCount As Long
Dim rgDirectorateListSource As Range

Set rgDirectorateListSource =
Worksheets("Data-Directorates").Range("DirectorateRange")
DirectorateCount = rgDirectorateListSource.count
End Sub

Do I need to use a ByVal Target as RANGE somewhere or what am I doing wrong?
Thanks
Matt



Nigel

Dynamic Named Range count
 
I do not see anything wrong. Is your named range DirectorateRange correctly
specified?

--
Cheers
Nigel



"Matt Jensen" wrote in message
...
Howdy
When I do a count of a dyanmic named range I get 1, when I do it for a
static named range I get the correct count of the range.
This is my code:

Private Sub UserForm_Initialize()
Dim DirectorateCount As Long
Dim rgDirectorateListSource As Range

Set rgDirectorateListSource =
Worksheets("Data-Directorates").Range("DirectorateRange")
DirectorateCount = rgDirectorateListSource.count
End Sub

Do I need to use a ByVal Target as RANGE somewhere or what am I doing

wrong?
Thanks
Matt





Matt Jensen

Dynamic Named Range count
 
It is defined like this
=OFFSET('Data-Directorates'!$A$1,0,0,COUNTA(DataDirectorates!$A: $A),1)
Cheers
Matt


"Nigel" wrote in message
...
I do not see anything wrong. Is your named range DirectorateRange

correctly
specified?

--
Cheers
Nigel



"Matt Jensen" wrote in message
...
Howdy
When I do a count of a dyanmic named range I get 1, when I do it for a
static named range I get the correct count of the range.
This is my code:

Private Sub UserForm_Initialize()
Dim DirectorateCount As Long
Dim rgDirectorateListSource As Range

Set rgDirectorateListSource =
Worksheets("Data-Directorates").Range("DirectorateRange")
DirectorateCount = rgDirectorateListSource.count
End Sub

Do I need to use a ByVal Target as RANGE somewhere or what am I doing

wrong?
Thanks
Matt







Matt Jensen

Dynamic Named Range count
 
My apologies
Typos were the problem, as can be seen in name definition formula.
Cheers
Matt

"Matt Jensen" wrote in message
...
It is defined like this
=OFFSET('Data-Directorates'!$A$1,0,0,COUNTA(DataDirectorates!$A: $A),1)
Cheers
Matt


"Nigel" wrote in message
...
I do not see anything wrong. Is your named range DirectorateRange

correctly
specified?

--
Cheers
Nigel



"Matt Jensen" wrote in message
...
Howdy
When I do a count of a dyanmic named range I get 1, when I do it for a
static named range I get the correct count of the range.
This is my code:

Private Sub UserForm_Initialize()
Dim DirectorateCount As Long
Dim rgDirectorateListSource As Range

Set rgDirectorateListSource =
Worksheets("Data-Directorates").Range("DirectorateRange")
DirectorateCount = rgDirectorateListSource.count
End Sub

Do I need to use a ByVal Target as RANGE somewhere or what am I doing

wrong?
Thanks
Matt









Bob Phillips[_6_]

Dynamic Named Range count
 
Matt,

As ever, it works fine for me. How do you define the dynamic range?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Matt Jensen" wrote in message
...
Howdy
When I do a count of a dyanmic named range I get 1, when I do it for a
static named range I get the correct count of the range.
This is my code:

Private Sub UserForm_Initialize()
Dim DirectorateCount As Long
Dim rgDirectorateListSource As Range

Set rgDirectorateListSource =
Worksheets("Data-Directorates").Range("DirectorateRange")
DirectorateCount = rgDirectorateListSource.count
End Sub

Do I need to use a ByVal Target as RANGE somewhere or what am I doing

wrong?
Thanks
Matt





Tom Ogilvy

Dynamic Named Range count
 
Your formula refers to two separate sheets

Data-Directorates
DataDirectorates

--
Regards,
Tom Ogilvy


"Matt Jensen" wrote in message
...
It is defined like this
=OFFSET('Data-Directorates'!$A$1,0,0,COUNTA(DataDirectorates!$A: $A),1)
Cheers
Matt


"Nigel" wrote in message
...
I do not see anything wrong. Is your named range DirectorateRange

correctly
specified?

--
Cheers
Nigel



"Matt Jensen" wrote in message
...
Howdy
When I do a count of a dyanmic named range I get 1, when I do it for a
static named range I get the correct count of the range.
This is my code:

Private Sub UserForm_Initialize()
Dim DirectorateCount As Long
Dim rgDirectorateListSource As Range

Set rgDirectorateListSource =
Worksheets("Data-Directorates").Range("DirectorateRange")
DirectorateCount = rgDirectorateListSource.count
End Sub

Do I need to use a ByVal Target as RANGE somewhere or what am I doing

wrong?
Thanks
Matt










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

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