Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
basel = A(2)
End Function Hi. Just a question. Are you sorting the array just to get the second smallest value? Maybe... A = Array(5, 3, 7, 1, 8) BaseL = WorksheetFunction.Small(A, 2) 'or Call SortArray(A) BaseL = A(2) You would have to adjust your indexes in case the LBound of your array is not 1. -- HTH :) Dana DeLouis Windows XP & Office 2007 "Arne Hegefors" wrote in message ... Hi! I have a problem with an array that I have in a udf. I send the array to another udf in order to sort the array. Somewhere there it goes wrong and the code stops. .. Call SortArray(A) basel = A(2) End Function ... Function SortArray(ByRef TheArray As Variant) Sorted = False Do While Not Sorted Sorted = True For X = 1 To UBound(TheArray) If TheArray(X) TheArray(X + 1) Then Temp = TheArray(X + 1) TheArray(X + 1) = TheArray(X) TheArray(X) = Temp Sorted = False End If Next X Loop End Function The sorting seems to work just fine but the code never goes back to the line basel = A(2). Instead it goes back to the line before the Call SortArray. I have no idea what is wrong. Please if anyone can help me! Thanks a lot! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Prevent cell/array references from changing when altering/moving thecell/array | Excel Discussion (Misc queries) | |||
meaning of : IF(Switch; Average(array A, array B); array A) | Excel Worksheet Functions | |||
Call Center Management: How to calculate 'cost per call' | Excel Discussion (Misc queries) | |||
Array problem: Key words-Variant Array, single-element, type mismatch error | Excel Programming | |||
Array problem: Key words-Variant Array, single-element, type mismatch error | Excel Programming |