I’ve run into a problem and don’t have a clue as to what I may be doing wrong.
Using VBA, I’m attempting to determine a number of Maximum and Minimum values in a very specific range of data. Here are some specifics about this range of data:
Applying the above formula to the chart below, I get the following results and I haven't a clue as to where those results are coming from.
Max1 = 5 <==== Exactly what I was expecting
Max2 = 0 <==== was expecting the second highest or 2
Any thoughts on what I may be doing wrong?
Using VBA, I’m attempting to determine a number of Maximum and Minimum values in a very specific range of data. Here are some specifics about this range of data:
- The data is located in a worksheet called CommonData and
- The data would exist between E5:X24.
- In the logic below, while using the Index function, I use the variable “n” to help limit the size of the chart that is to be examined. Note: “n” is passed along based on the number of players being used.
VBA Code:
Dim wsName2 As String
Dim n As Long
wsName2 = “CommonData”
'n = nPlayers Note: nPlayers is a variable that is dynamically set based on the number of players being examined. In this example, I am simply setting the variable to 12
n = 12
With Sheets(wsName2)
Max1 = Evaluate("=LARGE(E5:INDEX(E5:X24," & n & "," & n & "),1)")
Max2 = Evaluate( "=MAX(IF(E5:INDEX(E5:X24," & n & "," & n & ")<Max1,E5:INDEX(E5:X24," & n & "," & n & ")))")
End With
Applying the above formula to the chart below, I get the following results and I haven't a clue as to where those results are coming from.
Max1 = 5 <==== Exactly what I was expecting
Max2 = 0 <==== was expecting the second highest or 2
Any thoughts on what I may be doing wrong?