Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() So I have to seperate arrays. I have a program written that will find the maximum value from one of the arrays. I need to have the program output a value from the second array that corresponds to the location of the max value from the first array. What should I use to correspond the two arrays in the end? -- NickCo7 ------------------------------------------------------------------------ NickCo7's Profile: http://www.excelforum.com/member.php...o&userid=33341 View this thread: http://www.excelforum.com/showthread...hreadid=531733 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() My maximum value looks like this. Option Explicit Option Base 1 Function MaxVal(DataArray) Dim NumRows As Integer, NumCols As Integer Dim i As Integer, j As Integer MaxVal = DataArray(1, 1) NumRows = DataArray.Rows.Count NumCols = DataArray.Columns.Count For i = 1 To NumRows For j = 1 To NumCols If DataArray(i, j) MaxVal Then MaxVal = DataArray(i, j) End If Next j Next i End Function -- NickCo7 ------------------------------------------------------------------------ NickCo7's Profile: http://www.excelforum.com/member.php...o&userid=33341 View this thread: http://www.excelforum.com/showthread...hreadid=531733 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() My interpretation... Jim Cone San Francisco, USA http://www.realezsites.com/bus/primitivesoftware Function MaxVal(ByRef DataArray() As Double, _ ByRef TheOtherArray() As Double) As Double Dim NumRows As Long Dim NumCols As Long Dim i As Long Dim j As Long Dim x As Long Dim y As Long MaxVal = DataArray(1, 1) NumRows = UBound(DataArray) NumCols = UBound(DataArray, 2) For i = 1 To NumRows For j = 1 To NumCols If DataArray(i, j) MaxVal Then x = i y = j End If Next j Next i MaxVal = TheOtherArray(x, y) End Function '---- Sub NewsgroupTestForMaxVal() 'Create two arrays and call the MaxVal function. Dim arrFirst() As Double Dim arrSecond() As Double Dim lngN As Long Dim x As Double ReDim arrFirst(1 To 4, 1 To 5) ReDim arrSecond(1 To 4, 1 To 5) 'Load the arrays For lngN = 1 To 4 For x = 1 To 5 arrFirst(lngN, x) = lngN + x * 2 arrSecond(lngN, x) = lngN + x * 3 Next Next 'For reference purposes, to check the result returned. 'Range("A1:E4").Value = arrFirst() 'Range("G1:K4").Value = arrSecond() 'Call the function x = MaxVal(arrFirst, arrSecond) MsgBox x End Sub '------------- "NickCo7" wrote in message My maximum value looks like this. Option Explicit Option Base 1 Function MaxVal(DataArray) Dim NumRows As Integer, NumCols As Integer Dim i As Integer, j As Integer MaxVal = DataArray(1, 1) NumRows = DataArray.Rows.Count NumCols = DataArray.Columns.Count For i = 1 To NumRows For j = 1 To NumCols If DataArray(i, j) MaxVal Then MaxVal = DataArray(i, j) End If Next j Next i End Function |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Easy question | Excel Discussion (Misc queries) | |||
Easy Question | Excel Discussion (Misc queries) | |||
Easy Question | Excel Worksheet Functions | |||
new user with easy question? not easy for me | New Users to Excel | |||
Probably the most easy question here... | Excel Programming |