LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Add to an Array

No add to end of array function

Dim v(1 to 100)
v(ubound(v)) = "value"

would place the value in the last element of the array - but you appear to
be talking about the next empty element and not actually the last element.

Your use of a counter is the way to do it.

Another would be to make the array dynamic and always to a Redim Preserve to
increase the size by 1 and add at the end. However, this is slower.

--
Regards,
Tom Ogilvy


"br_turnbull"
wrote in message
...

I have some VBA code which takes information from checkboxes on a form.
There are 10 check boxes and basicaly i want to go through a series of
if statements whe

if chkBox1 = True
array(0) = "AA"
if chkBox2 = True
array(1) = "BB"

..etc

But obviously this would only work if all check boxes were selected,
how would i go about adding to the end of array no matter how many
values are already stored in it?

I was thinking something like

counter = 0

if chkBox1 = True
array(counter) = "AA"
counter = counter + 1
else
'do nothing
if chkBox2 = True
array(counter) = "BB"
counter = counter +1
else
'do nothing

But was just wondering if there was any kind of add to end of array
function I could call?

Also, is it possible to return the length of an array? i.e how many
values are stored in it?

Thanks in advance


--
br_turnbull
------------------------------------------------------------------------
br_turnbull's Profile:

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



 
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
Complex conditional summing - array COUNT works, array SUM gives#VALUE fatcatfan Excel Worksheet Functions 4 November 18th 09 06:41 PM
Prevent cell/array references from changing when altering/moving thecell/array nme Excel Discussion (Misc queries) 1 September 19th 08 01:53 PM
meaning of : IF(Switch; Average(array A, array B); array A) DXAT Excel Worksheet Functions 1 October 24th 06 06:11 PM
Assigning 10x1 array to 2nd collumn of 10x3 array Myrna Larson Excel Programming 0 July 29th 04 11:57 PM
variant array containing cel adresses convert to actual ranges-array Peter[_21_] Excel Programming 5 December 10th 03 09:50 PM


All times are GMT +1. The time now is 12:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"