View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
sebastienm sebastienm is offline
external usenet poster
 
Posts: 694
Default RE-Post Max Function not working properly on 2D Array

Hi,

1. I would make sure the array returned by INDEX is correct:
Dim v
v= Application.WorksheetFunction.Index(s, , 1)
then print each element.
Same with Index(s, , 2)

2. If your 2d array correspond to a range, you can use the
Appplication.Evaluate function to get what you need, Eg:
Application.Evaluate("=max(INDEX(G3:H6,,1))")

--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"ExcelMonkey" wrote:

I have a 2D array which I set up as a 2 columns and X Rows. I transpose it
to be X Rows by 2 Columns. I then test the max of the array and get an odd
result. The code is quite extensive but here is the just.

I set a break point and I print the transposed array contents to the
Immediate window in the first loop I get the following using the code below:
For X = 0 To UBound(NumberSetArray, 1)
Debug.Print NumberSetArray(X, 0) & ","; NumberSetArray(X, 1)
Next

I get the following in the Immediate Window:
7, 49

Immediately after printing tot the Immediate Window, I test for a max value
in the Immediate window using:
?Application.WorksheetFunction.Max(Application.Ind ex(NumberSetArray, , 1))
I get a value of 0.

Shouldn't the result be 7?

Whe I do the same test on the second column of the array I get:
?Application.WorksheetFunction.Max(Application.Ind ex(NumberSetArray, , 2))
52

Which I know to be correct.

Have I set the Index up incorrectly when attempting to apply the min
function to the first column

Thanks

EM