Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You've declared your arrays with no specific data type, so they are by
default variants. Variants could contain strings, numbers, or errors, and only an array of numbers can have a valid minimum. What types of values do the arrays contain? You need to check each array element to be certain. - Jon ------- Jon Peltier, Microsoft Excel MVP Tutorials and Custom Solutions Peltier Technical Services, Inc. - http://PeltierTech.com _______ "DJMF" wrote in message ... I have an array of numbers that I have calculated by multiplying the contents of two other VBA arrays. I need to calculate the minimum value of the final calculated array, and I can't get the worksheetfunction.min to work (although it works for arrays read directly into VBA from a worksheet). According to the error there is a type mismatch, but no matter what I do with definitions, I can't get it to work. Here is a cut-out section of the code with the offending line at the bottom. Thanks Dim a, b, c, Counta, Countb, MaxData, MinimumValue Dim CombinedData, CombinedRelativeFrequency Cells(9, 1).Select Range(Selection, Selection.End(xlDown)).Select Counta = Application.WorksheetFunction.Count(Selection) Cells(9, 5).Select Range(Selection, Selection.End(xlDown)).Select Countb = Application.WorksheetFunction.Count(Selection) Dim A3(1 To 1000, 1 To 2) Dim A4(1 To 1000, 1 To 2) Dim A5(1 To 1000000, 1 To 2) Dim A6(1 To 1000, 1 To 2) Dim A7(1 To 1000000, 1 To 2) Dim A8(1 To 1000000) Dim A9(1 To 1000000, 1 To 2) Dim A10(1 To 1000000) c = 0 For a = 1 To Counta A3(a, 1) = Cells(8 + a, 1).Value A3(a, 2) = Cells(8 + a, 2).Value For b = 1 To Countb A4(b, 1) = Cells(8 + b, 5).Value A4(b, 2) = Cells(8 + b, 6).Value c = c + 1 CombinedData = A3(a, 1) * A4(b, 1) CombinedRelativeFrequency = A3(a, 2) * A4(b, 2) If CombinedRelativeFrequency 0 Then A5(c, 1) = CombinedData A8(c) = CombinedData A5(c, 2) = CombinedRelativeFrequency Else c = c - 1 End If Next b Next a For d = 1 To Countd MinimumValue = Application.WorksheetFunction.Min(A8()) |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
calculate cell value with a minimum to be displayed | Excel Discussion (Misc queries) | |||
need help with if statement that calculate minimum figure | Excel Worksheet Functions | |||
How to calculate non-zero minimum value? | Excel Discussion (Misc queries) | |||
How to calculate minimum distance between three coordinate with ex | Excel Discussion (Misc queries) | |||
Calculate Minimum numbers | Excel Worksheet Functions |