VBA IFERROR syntax problem

ArfArfArf

Board Regular
Joined
Apr 14, 2011
Messages
51
I am trying to evaulate the value of a cell under three conditions

1. If IsError(Range(strAdd).Offset(0, y - 1).Value)
Or
2. Range(strAdd).Offset(0, y - 1).Value = ""
Or
3. Range(strAdd).Offset(0, y - 1).Value = 1 Then

1 is causing the problem. On its own it runs fine, and gives me the result I expect. If I try to combine it with the other two. i.e.

HTML:
If IsError(Range(strAdd).Offset(0, y - 1).Value) Or Range(strAdd).Offset(0, y - 1).Value = "" Or Range(strAdd).Offset(0, y - 1).Value = 1 Then

it causes the code to fail. I'm sure its a small correction but I can't see it.

Thanks

Arf
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
You'll have to do it on seperate lines..

Because even though you're testing the range for error, EVERY argument in the OR is tested..
so if the Range is an error, it's STILL testing if that error = ""...resulting in an error.

so you have to break it out into seperate lines..

Code:
IF IsError(Range(strAdd).Offset(0, y - 1).Value) Then
    Do this
Else
    If Range(strAdd).Offset(0, y - 1).Value = "" Or Range(strAdd).Offset(0, y - 1).Value = 1 Then
        Do this
    End if
End If
 
Upvote 0

Forum statistics

Threads
1,215,004
Messages
6,122,659
Members
449,091
Latest member
peppernaut

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