Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Regarding the Arrays | Excel Discussion (Misc queries) | |||
Arrays | Excel Discussion (Misc queries) | |||
Need help with arrays (I think) | Excel Programming | |||
Arrays | Excel Programming | |||
Arrays | Excel Programming |