Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel自定义项以统计错误_Excel_Vba_Count_User Defined Functions_Excel Udf - Fatal编程技术网

Excel自定义项以统计错误

Excel自定义项以统计错误,excel,vba,count,user-defined-functions,excel-udf,Excel,Vba,Count,User Defined Functions,Excel Udf,我试图在Excel VBA中编写一个UDF,用于计算错误(#NA!,#REF!…)。 我试图将Excel公式翻译成VBA语言,但没有成功。 有人知道解决办法吗 谢谢怎么样 Public Function CountErr(cells As range) As Long Dim cell As range For Each cell In cells If Application.WorksheetFunction.IsError(cell) Then CountErr =

我试图在Excel VBA中编写一个UDF,用于计算错误(#NA!,#REF!…)。 我试图将Excel公式翻译成VBA语言,但没有成功。 有人知道解决办法吗

谢谢

怎么样

Public Function CountErr(cells As range) As Long
   Dim cell As range
   For Each cell In cells
      If Application.WorksheetFunction.IsError(cell) Then CountErr = CountErr + 1
   Next
End Function