deleting data in vba array
Robert,
If it is the last item that is to be deleted, you can Redim Preserve as with
adding.
If it is not the last item, you will need to shuffle all remaining items
back one and then Redim, sort of like
For i = 10 To UBound(aryNums,1) -1
aryNums(i) =aryNum(i+1)
Next i
Redim Preserve aryNums(UBound(aryNums,1)-1
--
HTH
-------
Bob Phillips
"RobcPettit" wrote in message
...
Hi, Im working with a dynamic array and have no problem assigning values
to an
array, or working with the array in general. What Im having difficulty is
deleting an item in the array then resizing. I know how to add items and
resize
using preserve. What Im doing is this. Say my array has 10 values, I use:
For I
= 1 to Ubound(myarray) then loop through the array looking to see if a
value
matches a certain criteria, if not I do nothing, if so (this bit I cant
do) I
want to remove that value from my array (leaving 9 values), resize the
array
then use my Ubound. Can this be done. Any advice would be appreciated
Regards Robert
|