单细胞总和和空白细胞

时间:2015-04-02 19:33:37

标签: excel-vba excel-formula excel-2013 vba excel

我正在使用此宏来汇总单个单元格中用逗号分隔的单个数字

Function Individual(R As Range) As Double
   Individual = Evaluate(Replace(R.Value, ",", "+"))
End Function

函数看起来像这样=个体(XY),其中XY是“源”单元格,其中写入了各个数字。

当“源”单元格为空时,如何修改宏以将0写入“目标”单元格?

1 个答案:

答案 0 :(得分:0)

Function Individual(R As Range) As Double
  if len(r.value) > 0 then
    Individual = Evaluate(Replace(R.Value, ",", "+"))
  else
    Individual = 0
  end if
End Function