ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Counting items in an array (https://www.excelbanter.com/excel-programming/317830-counting-items-array.html)

ajitpalsingh200[_20_]

Counting items in an array
 

How do i count the number of items in array

lets say i have declaration as below

DiscreteData = Array("MPN", "Vendor")

How do i count the items?

thankx in adavanc

--
ajitpalsingh20
-----------------------------------------------------------------------
ajitpalsingh200's Profile: http://www.excelforum.com/member.php...fo&userid=1615
View this thread: http://www.excelforum.com/showthread.php?threadid=32051


NickHK

Counting items in an array
 
ajitpalsingh200,

Dim ArrayItemCount as Long
ArrayItemCount =UBound(DiscreteData)-LBound(DiscreteData)

NickHK

"ajitpalsingh200" wrote in
message ...

How do i count the number of items in array

lets say i have declaration as below

DiscreteData = Array("MPN", "Vendor")

How do i count the items?

thankx in adavance


--
ajitpalsingh200
------------------------------------------------------------------------
ajitpalsingh200's Profile:

http://www.excelforum.com/member.php...o&userid=16150
View this thread: http://www.excelforum.com/showthread...hreadid=320512




Alan Beban[_2_]

Counting items in an array
 
NickHK wrote:
ajitpalsingh200,

Dim ArrayItemCount as Long
ArrayItemCount =UBound(DiscreteData)-LBound(DiscreteData)

NickHK


The above works for a 1-based array; to allow for a 0-based or 1-based
array, substitute
ArrayItemCount =UBound(DiscreteData)-LBound(DiscreteData) + 1

Alan Beban

"ajitpalsingh200" wrote in
message ...

How do i count the number of items in array

lets say i have declaration as below

DiscreteData = Array("MPN", "Vendor")

How do i count the items?

thankx in adavance


--
ajitpalsingh200
------------------------------------------------------------------------
ajitpalsingh200's Profile:


http://www.excelforum.com/member.php...o&userid=16150

View this thread: http://www.excelforum.com/showthread...hreadid=320512





AA2e72E

Counting items in an array
 
There is no built-in support for finding the dimensions of an array in VBA/VB
without prior knowledge of its rank (number of dimensions). The nearest
solution is to do it by trial and error.

"Alan Beban" wrote:

NickHK wrote:
ajitpalsingh200,

Dim ArrayItemCount as Long
ArrayItemCount =UBound(DiscreteData)-LBound(DiscreteData)

NickHK


The above works for a 1-based array; to allow for a 0-based or 1-based
array, substitute
ArrayItemCount =UBound(DiscreteData)-LBound(DiscreteData) + 1

Alan Beban

"ajitpalsingh200" wrote in
message ...

How do i count the number of items in array

lets say i have declaration as below

DiscreteData = Array("MPN", "Vendor")

How do i count the items?

thankx in adavance


--
ajitpalsingh200
------------------------------------------------------------------------
ajitpalsingh200's Profile:


http://www.excelforum.com/member.php...o&userid=16150

View this thread: http://www.excelforum.com/showthread...hreadid=320512






Rob van Gelder[_4_]

Counting items in an array
 
I have an example of how to determine number of dimensions in array on my
website "Number of Dimensions"

My routine trials until it errors - just as you say.

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"AA2e72E" wrote in message
...
There is no built-in support for finding the dimensions of an array in
VBA/VB
without prior knowledge of its rank (number of dimensions). The nearest
solution is to do it by trial and error.

"Alan Beban" wrote:

NickHK wrote:
ajitpalsingh200,

Dim ArrayItemCount as Long
ArrayItemCount =UBound(DiscreteData)-LBound(DiscreteData)

NickHK


The above works for a 1-based array; to allow for a 0-based or 1-based
array, substitute
ArrayItemCount =UBound(DiscreteData)-LBound(DiscreteData) + 1

Alan Beban

"ajitpalsingh200" wrote
in
message ...

How do i count the number of items in array

lets say i have declaration as below

DiscreteData = Array("MPN", "Vendor")

How do i count the items?

thankx in adavance


--
ajitpalsingh200
------------------------------------------------------------------------
ajitpalsingh200's Profile:

http://www.excelforum.com/member.php...o&userid=16150

View this thread:
http://www.excelforum.com/showthread...hreadid=320512








AA2e72E

Counting items in an array
 
If you simply want the count of the number of elements in an array,
irrespection of the humber of dimensions it has, try:

Sub xy()

For Each ele In xx
cnt = cnt + 1
Next
End Sub

"Rob van Gelder" wrote:

I have an example of how to determine number of dimensions in array on my
website "Number of Dimensions"

My routine trials until it errors - just as you say.

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"AA2e72E" wrote in message
...
There is no built-in support for finding the dimensions of an array in
VBA/VB
without prior knowledge of its rank (number of dimensions). The nearest
solution is to do it by trial and error.

"Alan Beban" wrote:

NickHK wrote:
ajitpalsingh200,

Dim ArrayItemCount as Long
ArrayItemCount =UBound(DiscreteData)-LBound(DiscreteData)

NickHK

The above works for a 1-based array; to allow for a 0-based or 1-based
array, substitute
ArrayItemCount =UBound(DiscreteData)-LBound(DiscreteData) + 1

Alan Beban

"ajitpalsingh200" wrote
in
message ...

How do i count the number of items in array

lets say i have declaration as below

DiscreteData = Array("MPN", "Vendor")

How do i count the items?

thankx in adavance


--
ajitpalsingh200
------------------------------------------------------------------------
ajitpalsingh200's Profile:

http://www.excelforum.com/member.php...o&userid=16150

View this thread:
http://www.excelforum.com/showthread...hreadid=320512









AA2e72E

Counting items in an array
 
If you simply want the count of the number of elements in an array,
irrespection of the humber of dimensions it has, try:

Sub xy()
cnt = 0
For Each ele In YourArray
cnt = cnt + 1
Next
End Sub

"Rob van Gelder" wrote:

I have an example of how to determine number of dimensions in array on my
website "Number of Dimensions"

My routine trials until it errors - just as you say.

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"AA2e72E" wrote in message
...
There is no built-in support for finding the dimensions of an array in
VBA/VB
without prior knowledge of its rank (number of dimensions). The nearest
solution is to do it by trial and error.

"Alan Beban" wrote:

NickHK wrote:
ajitpalsingh200,

Dim ArrayItemCount as Long
ArrayItemCount =UBound(DiscreteData)-LBound(DiscreteData)

NickHK

The above works for a 1-based array; to allow for a 0-based or 1-based
array, substitute
ArrayItemCount =UBound(DiscreteData)-LBound(DiscreteData) + 1

Alan Beban

"ajitpalsingh200" wrote
in
message ...

How do i count the number of items in array

lets say i have declaration as below

DiscreteData = Array("MPN", "Vendor")

How do i count the items?

thankx in adavance


--
ajitpalsingh200
------------------------------------------------------------------------
ajitpalsingh200's Profile:

http://www.excelforum.com/member.php...o&userid=16150

View this thread:
http://www.excelforum.com/showthread...hreadid=320512










All times are GMT +1. The time now is 01:44 PM.

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