Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default How do I find the number of elements in an Array of Strings?

I'm programming VBA in Excel 2003.
I wish to index through a loop for each element in an array. But I need to
refer to the elements by their index number, not their value as a string.
How can I find the number of elements in an array of strings?
Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default How do I find the number of elements in an Array of Strings?

BeefmanSteve wrote:
I'm programming VBA in Excel 2003.
I wish to index through a loop for each element in an array. But I need to
refer to the elements by their index number, not their value as a string.
How can I find the number of elements in an array of strings?
Thanks.

UBound(MyArray) - LBound(MyArray) + 1

Alan Beban
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default How do I find the number of elements in an Array of Strings?

Hi BeefmanSteve,

Sub Tester()
Dim Arr As Variant
Dim NumOfElements As Long

Arr = Array("aaa", "bbb", "cccc")
NumOfElements = UBound(Arr) - LBound(Arr) + 1
MsgBox NumOfElements

End Sub

---
Regards,
Norman



"BeefmanSteve" wrote in message
...
I'm programming VBA in Excel 2003.
I wish to index through a loop for each element in an array. But I need
to
refer to the elements by their index number, not their value as a string.
How can I find the number of elements in an array of strings?
Thanks.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default How do I find the number of elements in an Array of Strings?

dim myArr as variant
dim iCtr as long
myarr = array("a","qwer","qwerqwer","asdf")

for ictr = lbound(myarr) to ubound(myarr)
msgbox myarr(ictr)
next ictr




BeefmanSteve wrote:

I'm programming VBA in Excel 2003.
I wish to index through a loop for each element in an array. But I need to
refer to the elements by their index number, not their value as a string.
How can I find the number of elements in an array of strings?
Thanks.


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default How do I find the number of elements in an Array of Strings?


For i = LBound(ary) To UBound(ary)
Debug.Print ary(i)
Next i

--

HTH

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


"BeefmanSteve" wrote in message
...
I'm programming VBA in Excel 2003.
I wish to index through a loop for each element in an array. But I need

to
refer to the elements by their index number, not their value as a string.
How can I find the number of elements in an array of strings?
Thanks.





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default How do I find the number of elements in an Array of Strings?

On Thu, 16 Jun 2005 16:08:01 -0700, BeefmanSteve
wrote:

I'm programming VBA in Excel 2003.
I wish to index through a loop for each element in an array. But I need to
refer to the elements by their index number, not their value as a string.
How can I find the number of elements in an array of strings?
Thanks.


Look at the LBound and UBound functions.


--ron
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
Maximum number of elements in array Juarez Excel Discussion (Misc queries) 1 December 9th 08 07:49 PM
Counting the Number of Elements in an Array Confused_in_Houston[_2_] Excel Discussion (Misc queries) 3 October 1st 08 11:05 PM
How to find number of pairs of strings from list of strings? greg_overholt Excel Worksheet Functions 5 January 27th 06 10:42 PM
What is the maximum allowed number of data elements in a data array? [email protected] Excel Discussion (Misc queries) 2 April 7th 05 06:56 PM
Counting the number of elements within an array that have data ExcelMonkey[_125_] Excel Programming 5 May 26th 04 05:14 PM


All times are GMT +1. The time now is 08:52 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"