IFERROR or Error On in VBA

BrittKnee

Board Regular
Joined
Dec 4, 2017
Messages
82
I am fairly new to coding in VBA and was wondering how to add an error formula to the following string of code:

For I = a To lastRow
If Range("I" & I).Value / Range("H" & I).Value > 1 Then
Range("P" & I).Value = "Review"
Range("Q" & I).Value = "Review"
Range("R" & I).Value = "Charity Adjustment > Total Charges"
End If

I need something that will set errors = 0 in the IF statement


Thanks
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Are the errors due to trying to divide by zero (if the value in column H is zero or blank), or are you talking about errors in column H or I?
And what is it that you are setting equal to zero?

If column H is zero, you can simply do something like:
Code:
If Range("H" & I).Value = 0 Then ...
 
Upvote 0
There are errors due to 0 being in the denominator. I would need to set the value of the formula (I/H) to 0

Thanks!
 
Last edited:
Upvote 0
Then use what I posted above.
Nest your other IF statement under this one, i.e.

Code:
[FONT=Verdana]For I = a To lastRow[/FONT]
    If Range("H" & I).Value = 0 Then
'       enter what you want to happen here when denominator is zero
    Else
        If Range("I" & I).Value / Range("H" & I).Value > 1 Then
            ...
 
Upvote 0

Forum statistics

Threads
1,214,908
Messages
6,122,187
Members
449,072
Latest member
DW Draft

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top