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

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
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,959
Messages
6,122,476
Members
449,087
Latest member
RExcelSearch

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