#DIV0!

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When I use this code, I'd like to divide cells, sometimes it's dividing by 0s
which results in #DIV0!, how can i make this return a zero instead? Or am I
using the wrong code?


Range("D59").Select
ActiveCell.FormulaR1C1 = "=(R[-1]C/R[-1]C[1])"
If IsError(ActiveCell.Value) Then
errval = ActiveCell.Value
Select Case errval
Case CVErr(xlErrRef)
ActiveCell.Value = 0
Case Else
' >>>>



End Select
End If
 
Awesome!!

Vergel Adriano said:
Try it this way:

ActiveCell.FormulaR1C1 = "=IF(R[-1]C[1]=0,0,(R[-1]C/R[-1]C[1]))"


--
Hope that helps.

Vergel Adriano


CV323 said:
When I use this code, I'd like to divide cells, sometimes it's dividing by 0s
which results in #DIV0!, how can i make this return a zero instead? Or am I
using the wrong code?


Range("D59").Select
ActiveCell.FormulaR1C1 = "=(R[-1]C/R[-1]C[1])"
If IsError(ActiveCell.Value) Then
errval = ActiveCell.Value
Select Case errval
Case CVErr(xlErrRef)
ActiveCell.Value = 0
Case Else
' >>>>



End Select
End If
 
Back
Top