执行" AVERAGEIF"时出现#DIV / 0错误

时间:2017-07-12 15:15:27

标签: excel vba excel-vba excel-formula word-vba

所以,我这里有一个执行AVERAGEIF的代码,但我总是得到#DIV / 0错误。我不知道这里的错误。我希望有人可以提供帮助。

     Dim aveif1
     Dim aveif2
     Dim aveval
     Dim totalave As Variant
     Dim colAve
     Dim aveSource As Range
     Dim aveCheck As Range
     Dim lCol 

     lCol = 19
     colAve = lCol + 1



    For aveif1 = 3 To ColBanner

        aveval = CStr(Cells(1, aveif1).Value)

       For aveif2 = 3 To RowBanner

            With Sheets("Rescaled Scores")

             totalave = Application.AverageIf(Columns(colAve), "Smartphone", Columns(aveif2))

            End With

        colAve = colAve + 1
        Cells(aveif2, aveif1).Value = totalave
        Columns.AutoFit

       Next aveif2



    Next aveif1

1 个答案:

答案 0 :(得分:0)

平均值是总和和除法。

你得到的是零除错误,表明你的一个数据集是空的。在这种情况下,您无法执行平均值,或者您将尝试除以零。