Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default 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




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 400
Default 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





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default 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









  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 400
Default 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








  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 400
Default 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








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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Counting Items Jakobshavn Isbrae Excel Worksheet Functions 20 June 22nd 08 09:27 PM
Array: Counting multiple values within array Trilux_nogo Excel Worksheet Functions 4 April 16th 07 03:12 AM
Counting the items Tyrone Lopez Excel Worksheet Functions 4 May 25th 06 07:51 AM
vba - counting different items abc2002 Excel Programming 2 August 12th 04 09:32 PM
Counting items Garry[_3_] Excel Programming 3 December 18th 03 01:42 PM


All times are GMT +1. The time now is 07:48 AM.

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"