PA HS Teacher
Well-known Member
- Joined
- Jul 17, 2004
- Messages
- 2,838
I am making an NCAA tournament spreadsheet. I wrote a user defined function that returns a certain number of points based the round number, and the seed number it is fed. This function appears to work under normal circumstances,
For example:=GamePoints($B$73,1)
returns 12, as it should based on my rules and the value in B73
However, when I enter the following Array entered formula:
=SUM(GamePoints($B$71:$B$73,1))
I get the
#VALUE! error
Is it possible to use a UDF within an Array formula? I can change the UDF to loop through a range itself, but it would be kind of nice to use this UDF in an array entered formula. If it is possible, does anyone know what the problem may be?
If it helps the following is the code for my GamePoints UDF
For example:=GamePoints($B$73,1)
returns 12, as it should based on my rules and the value in B73
However, when I enter the following Array entered formula:
=SUM(GamePoints($B$71:$B$73,1))
I get the
#VALUE! error
Is it possible to use a UDF within an Array formula? I can change the UDF to loop through a range itself, but it would be kind of nice to use this UDF in an array entered formula. If it is possible, does anyone know what the problem may be?
If it helps the following is the code for my GamePoints UDF
Code:
Function GamePoints(iRound As Integer, iSeed As Integer) As Integer
Dim iRegularPoints As Integer, iMaxSeed As Integer, iSeedFactor As Integer
iRegularPoints = Application.WorksheetFunction.VLookup(iRound, Worksheets("Seeds").Range("F2:I8"), 2, 0)
iMaxSeed = Application.WorksheetFunction.VLookup(iRound, Worksheets("Seeds").Range("F2:I8"), 4, 0)
iSeedFactor = Application.WorksheetFunction.VLookup(iRound, Worksheets("Seeds").Range("F2:I8"), 3, 0)
If iMaxSeed <= iSeed Then
GamePoints = iRegularPoints * iSeedFactor
Else
GamePoints = iRegularPoints
End If
End Function