LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default

"Alan Beban" wrote...
There *is* a limitation on the lines of code I suggested below, at least
in xl versions up through xl2000 (and perhaps later as well, I don't
know), though it's not a limitation on the aresize code. I don't know
if it's relevant because I don't know how large your data will get to
be, but the Index function as used below will fail if the number of
elements of Array1 in the first two dimensions exceeds 5461.

This limitation can be avoided if the functions in the freely
downloadable file at http://home.pacbell.net/beban are available to your
workbook, a la

...

If the goal is iterating over the subarray for which the 3rd of 5 dimensions
equals 9, using aresize to coerce to 2D followed by ColumnVector followed by
another aresize call to restore 5D is grossly wasteful of system resources. It'd
be simpler to use something like the following to find the max value in all
entries in the subarray Array1(.,.,9,.,.).


Dim d(1 To 6) As Long, i As Long, x As Variant, maxval As Variant

'one more dimension in d than in Array1
d(1) = 1
For i = 2 To 6
d(i) = d(i - 1) * UBound(Array1, i - 1) 'assuming Array1 is 1-based
Next i

i = 0
For Each x In Array1

i = i + 1

If Int(1 + ((i - 1) Mod d(4)) / d(3)) = 9 Then
If IsEmpty(maxval) Or x maxval Then maxval = x
End If

Next x


This could be the core of a general purpose array slicing function, but I'm too
lazy right now to implement it. To create a subarray aa for which the 3rd of 5
dimensions is 9, define aa using

ReDim aa(1 To UBound(Array1, 1), 1 To UBound(Array1, 2), _
1 To UBound(Array1, 4), 1 To UBound(Array1, 5))

and replace the 'If IsEmpty...' statement in the code above with

aa(Int(1 + ((i - 1) Mod d(2)) / d(1)), Int(1 + ((i - 1) Mod d(3)) / d(2)), _
Int(1 + ((i - 1) Mod d(5)) / d(4)), Int(1 + ((i - 1) Mod d(6)) / d(5))) = x

While d(1) and d(6) are technically unnecessary, they simplify iterative
techniques for generating the indices of aa as you iterate through Array1 using
For Each.

--
To top-post is human, to bottom-post and snip is sublime.
 
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
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
"Resizing cells" code doesn't work with merged cells Gina Excel Discussion (Misc queries) 2 June 30th 08 01:37 PM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
Resizing a field in "forms" GlennO Setting up and Configuration of Excel 0 July 6th 06 03:40 PM
Looking for VB code to test for "RING" , "BUSY" disconnects or other signals BruceJ[_2_] Excel Programming 3 November 20th 03 01:55 AM


All times are GMT +1. The time now is 02:49 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"