[英]#value error returns with excel user defined function
我創建了用戶定義的函數來計算足球比賽結果。
我的根函數看起來:
Function calculatePoints(personTypes As Range, matchesResults As Range) As Integer
calculatePoints = getAllPersonPoints(personTypes, matchesResults)
End Function
getAllPersonPoints函數:
Private Function getAllPersonPoints(personTypes As Range, matchesResults
AsRange) As Integer
Dim x As Long
Dim y As Long
Dim isTheSurest As Boolean
getAllPersonPoints = 0
For x = 1 To personTypes.Rows.Count
For y = 1 To personTypes.Columns.Count
isTheSurest = isTheSurestResult(personTypes.Cells(x,
y).DisplayFormat.Interior.PatternColorIndex)
getAllPersonPoints = getAllPersonPoints +
getPoints(matchesResults.Cells(x, y).Value, personTypes.Cells(x, y).Value,
isTheSurest)
Next y
Next x
End Function
當我嘗試通過手動設置參數來調用此功能時:personTypes range和matchResults ragne-everythink正常運行。
但是,當我嘗試從工作表中調用它時,在選定的單元格中出現了#VALUE錯誤。
但是在函數形式中有正確的結果:
一個一直在嘗試調試返回值,並且我總是得到正確的值。 我只有問題與返回單元格中的錯誤。
有任何想法嗎 ?
我通過代碼解決了問題:
personTypes.Cells(x, y).Interior.ColorIndex
代替:
personTypes.Cells(x,y).DisplayFormat.Interior.PatternColorIndex
此解決方案有效。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.