Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default Deleting element in Array

I have a 1-D array. A Routine checks the cells in a range
and fills it (based on a test - boolean) with cell
addresses. I want to run a second routine, which checks
this same range and performs another test - boolean. If
the boolean is false and this particular cell address
already exists in the array, then I want to delete its
existence in the array. How do I do this and redimension
the array so that it no longer includes the deleted
elements. THanks


?Array(0)
$A$1
?Array(1)
$A$2
?Array(2)
$A$3

After the second check I would like to see:
?Array(0)
$A$1
?Array(1)
$A$3
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Deleting element in Array

If speed is not an issue this might be easier with a collection.
Lookup Collection Object in the VBA help.

RBS


"ExcelMonkey" wrote in message
...
I have a 1-D array. A Routine checks the cells in a range
and fills it (based on a test - boolean) with cell
addresses. I want to run a second routine, which checks
this same range and performs another test - boolean. If
the boolean is false and this particular cell address
already exists in the array, then I want to delete its
existence in the array. How do I do this and redimension
the array so that it no longer includes the deleted
elements. THanks


?Array(0)
$A$1
?Array(1)
$A$2
?Array(2)
$A$3

After the second check I would like to see:
?Array(0)
$A$1
?Array(1)
$A$3


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Deleting element in Array

I think you have two choices in removing an element from an array - either
create a second array missing this element or move every element up one
place in the array and redim preserve it.

--
Jim
"ExcelMonkey" wrote in message
...
I have a 1-D array. A Routine checks the cells in a range
and fills it (based on a test - boolean) with cell
addresses. I want to run a second routine, which checks
this same range and performs another test - boolean. If
the boolean is false and this particular cell address
already exists in the array, then I want to delete its
existence in the array. How do I do this and redimension
the array so that it no longer includes the deleted
elements. THanks


?Array(0)
$A$1
?Array(1)
$A$2
?Array(2)
$A$3

After the second check I would like to see:
?Array(0)
$A$1
?Array(1)
$A$3



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default Deleting element in Array

ExcelMonkey wrote:
I have a 1-D array. A Routine checks the cells in a range
and fills it (based on a test - boolean) with cell
addresses. I want to run a second routine, which checks
this same range and performs another test - boolean. If
the boolean is false and this particular cell address
already exists in the array, then I want to delete its
existence in the array. How do I do this and redimension
the array so that it no longer includes the deleted
elements. THanks


?Array(0)
$A$1
?Array(1)
$A$2
?Array(2)
$A$3

After the second check I would like to see:
?Array(0)
$A$1
?Array(1)
$A$3

I don't understand what's going on with the boolean test, but you might
want to consider something like

Sub xy10000()
arr = Array(1, 2, 3, 3, 4)
Set x = New Dictionary
On Error Resume Next
For Each Elem In arr
x.Add Item:=Elem, key:=CStr(Elem)
Next
arr = x.Items
End Sub

Alan Beban
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
Permutations of an array element < to a value Bruce Excel Worksheet Functions 3 January 31st 06 04:00 PM
Deleting an element in the middle of an array Mike NG Excel Programming 20 March 15th 05 09:04 AM
Array element Andrea[_8_] Excel Programming 5 December 7th 04 08:24 PM
Deleting data and element in a 1D array ExcelMonkey[_124_] Excel Programming 11 May 17th 04 06:29 AM
deleting array element michael Excel Programming 0 December 18th 03 08:55 PM


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