Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default conditionally delete some elements from an array


I have an one-dimensional array that contains 11 elements. Now I only
need 3 elements and want to discard the rest from the array. So my
final array has only 3 elements. I need to code something like:
for i=1 to hbound(myarray)
if myarray ^in ('A, 'B', 'C') then delete
next

How to code it though? Thanks!


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

~~Now Available: Financial Statements.xls, a step by step guide to creating financial statements
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 473
Default conditionally delete some elements from an array

Clui wrote:
I have an one-dimensional array that contains 11 elements. Now I only
need 3 elements and want to discard the rest from the array. So my
final array has only 3 elements. I need to code something like:
for i=1 to hbound(myarray)
if myarray ^in ('A, 'B', 'C') then delete
next


Easiest is to create a new array with the content that you require.

Or, if it is a dynamic array then you could move the items you want to
the first 3 elements and ReDim Preserve MyArray(1 To 3)

Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - reply in newsgroup

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
Conversion of Array Elements to PerCent Confused_in_Houston Excel Discussion (Misc queries) 2 October 2nd 08 03:58 AM
Use formulas for array elements hmm Excel Discussion (Misc queries) 3 December 3rd 07 01:15 PM
Reference Elements w/in an Array M Moore Excel Discussion (Misc queries) 2 October 16th 06 03:33 PM
Non-unique elements in an array Andrew Excel Discussion (Misc queries) 1 August 22nd 05 11:58 AM
Q: Better syntax to cycle through elements of an array? Tushar Mehta Excel Programming 0 October 12th 03 05:19 PM


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