Division by 0 error on Worksheet_Change code

  • Hello,
    Hoping I can get some help with a problem I'm having, below is a snipit of code from my worksheet_change code. The Case numbers reference columns R and S on my spreadsheet. I am doing simple division, S/R and post answer in Column Q. It works fine in I enter data in column R then Column S but If I enter data in Column S first I get a division by 0 error. I would like to prevent this as the end user of the spreadsheet may enter the values in any order.


    Can someone please help. Thanks


    Code
    Case Is = 19
     If Target.Value <> "" Then
     Target.Offset(, -2) = Target / Target.Offset(, -1)
     End If
     
     Case Is = 18
     If Target.Value <> "" Then
     Target.Offset(, -1) = Target.Offset(, 1) / Target
     End If
  • Re: Division by 0 error on Worksheet_Change code


    Maybe this. :cool:


Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!