deleting data in vba array
If you are willing to work with the values as strings until you are
finished, perhaps another way.. The "Filter" command converts the initial
integers to strings.
Sub Demo()
Dim v
Dim Unique
Unique = Chr(255)
v = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
' Your code to remove the 5th & 9th item
' This example is "Zero" based, so index is 4 & 8
v(4) = Unique
v(8) = Unique
'Now, delete them...
v = Filter(v, Unique, False)
End Sub
--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =
"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
|