#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default arrays

i want to delete certain array elements
e.g.
dim arr(100)
deleted arr(87)
redim preserve arr(100-n) ' n= number of elements i deletd
any ideas?
--
hemu
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default arrays

I think you would have to move the non-sparse elements to a new array, and
then move them back. Nothing built-in AFAIK.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Hemant_india" wrote in message
...
i want to delete certain array elements
e.g.
dim arr(100)
deleted arr(87)
redim preserve arr(100-n) ' n= number of elements i deletd
any ideas?
--
hemu



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 200
Default arrays

Hemant_india wrote:
i want to delete certain array elements
e.g.
dim arr(100)
deleted arr(87)
redim preserve arr(100-n) ' n= number of elements i deletd
any ideas?

If the functions in the freely downloadable file at
http://home.pacbell.net/beban are available to your workbook,

To remove elements 45, 68 and 87, and resize

n1 = 45
n2 = 68
n3 = 87

arr2 = MakeArray(SubArray(arr, 1, n1 - 1), SubArray(arr, n1 + 1, _
n2 - 1), SubArray(arr, n2 + 1, n3 - 1), SubArray(arr, n3 + 1, 100), 1)

Or, it it helps you to visualize more readily what's happening
Sarr1 = SubArray(arr, 1, n1 - 1)
Sarr2 = SubArray(arr, n1 + 1, n2 - 1)
Sarr3 = SubArray(arr, n2 + 1, n3 - 1)
Sarr4 = SubArray(arr, n3 + 1, UBound(arr))
arr2 = MakeArray(Sarr1, Sarr2, Sarr3, Sarr4, 1)

Alan Beban
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 200
Default arrays

Sorry; I used Dim arr(1 to 100)

For a 0-based array you need to generalize Sarr1 to
Sarr1 = SubArray(arr, lbound(arr), n1 - 1) and change the last parameter
of the MakeArray call:

arr2 = MakeArray(Sarr1, Sarr2, Sarr3, Sarr4, 0)

And the introduction should more accurately be "To remove elements
arr(45), arr(68) and arr(87) . . ."

Alan Beban

Alan Beban wrote:
Hemant_india wrote:
i want to delete certain array elements
e.g.
dim arr(100)
deleted arr(87)
redim preserve arr(100-n) ' n= number of elements i deletd
any ideas?

If the functions in the freely downloadable file at
http://home.pacbell.net/beban are available to your workbook,

To remove elements 45, 68 and 87, and resize

n1 = 45
n2 = 68
n3 = 87

arr2 = MakeArray(SubArray(arr, 1, n1 - 1), SubArray(arr, n1 + 1, _
n2 - 1), SubArray(arr, n2 + 1, n3 - 1), SubArray(arr, n3 + 1, 100), 1)

Or, it it helps you to visualize more readily what's happening
Sarr1 = SubArray(arr, 1, n1 - 1)
Sarr2 = SubArray(arr, n1 + 1, n2 - 1)
Sarr3 = SubArray(arr, n2 + 1, n3 - 1)
Sarr4 = SubArray(arr, n3 + 1, UBound(arr))
arr2 = MakeArray(Sarr1, Sarr2, Sarr3, Sarr4, 1)

Alan Beban

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default arrays

hi alan
sorry replying so late
my PC was down
i have downloaded the code
thanks
--
hemu


"Alan Beban" wrote:

Sorry; I used Dim arr(1 to 100)

For a 0-based array you need to generalize Sarr1 to
Sarr1 = SubArray(arr, lbound(arr), n1 - 1) and change the last parameter
of the MakeArray call:

arr2 = MakeArray(Sarr1, Sarr2, Sarr3, Sarr4, 0)

And the introduction should more accurately be "To remove elements
arr(45), arr(68) and arr(87) . . ."

Alan Beban

Alan Beban wrote:
Hemant_india wrote:
i want to delete certain array elements
e.g.
dim arr(100)
deleted arr(87)
redim preserve arr(100-n) ' n= number of elements i deletd
any ideas?

If the functions in the freely downloadable file at
http://home.pacbell.net/beban are available to your workbook,

To remove elements 45, 68 and 87, and resize

n1 = 45
n2 = 68
n3 = 87

arr2 = MakeArray(SubArray(arr, 1, n1 - 1), SubArray(arr, n1 + 1, _
n2 - 1), SubArray(arr, n2 + 1, n3 - 1), SubArray(arr, n3 + 1, 100), 1)

Or, it it helps you to visualize more readily what's happening
Sarr1 = SubArray(arr, 1, n1 - 1)
Sarr2 = SubArray(arr, n1 + 1, n2 - 1)
Sarr3 = SubArray(arr, n2 + 1, n3 - 1)
Sarr4 = SubArray(arr, n3 + 1, UBound(arr))
arr2 = MakeArray(Sarr1, Sarr2, Sarr3, Sarr4, 1)

Alan Beban




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 200
Default arrays

Hemant_india wrote:
hi alan
sorry replying so late
my PC was down
i have downloaded the code
thanks

Thanks for the feedback.
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
Regarding the Arrays Raj Excel Discussion (Misc queries) 1 December 10th 08 02:26 PM
Arrays Tobro88 Excel Discussion (Misc queries) 3 November 18th 05 11:28 PM
Need help with arrays (I think) rbhedal Excel Programming 1 October 19th 05 12:41 PM
Arrays JAmes L Excel Programming 3 April 21st 04 11:00 AM
Arrays Luis Neves Excel Programming 1 February 13th 04 01:29 AM


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