ORDER OF OPERATION - IF statements counter-acting previous IF statements

Sphinx404

Board Regular
Joined
May 2, 2015
Messages
186
Office Version
  1. 365
Platform
  1. Windows
I've tried each of these IF statements in all the orders that seem logical but I think there is something wrong with the IF statement highlighted below.

Essentially what I am telling my ELSEIF to do:
If TRUE already exists in the cell, then leave it be, keep it true and move on.

Instead it bypasses it, and changes it to "Within Limits" or "Outside Limits".

I've changed it around where the highlighted text is the first IF statement, but that doesn't work either.

I thought IF statements found the first TRUE statement and then bypassed everything else?

Code:
For i = 2 To lrow


Set mycell = myworksheet.Range("AK" & i) 'Contains Unit of Measure
Set mycell2 = myworksheet.Range("AD" & i) 'Contains UN/ID#
Set mycell3 = myworksheet.Range("AM" & i) 'Contains static part #


    If mycell.Value = "L" And mycell2.Value = "UN3363" Then 'if UOM is L and UN/ID# is 3363 then
        mycell.Offset(, 2).Formula = "=IFERROR(IF(AL" & i & "=AJ" & i & ",TRUE,FALSE),""Error"")" '
        
[B][COLOR=#0000ff]        ElseIf mycell3 = "TRUE" Then[/COLOR][/B]
[B][COLOR=#0000ff]            mycell3 = "TRUE"[/COLOR][/B]
    Else
        mycell.Offset(, 2).Formula = "=IFERROR(IF(ABS(AJ" & i & " - AL" & i & ") <= AL" & i & "*0.1, ""Within Limit"", ""Outside Limit""),""Error"")"


End If

Next
 
Last edited:

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Try removing the quotes.... If the cell contains a formula, and that formula looks like it's returning Boolean True or False values.
That will not be a match to the TEXT string "TRUE"
 
Last edited:
Upvote 0
I cannot believe that worked. I am just... confounded. It absolutely makes sense, but I guess in this case, the devil is in the details.

:( I'm disappointed in myself. Thank you @Jonmo1

You fixed it for me. Just as I'm going to start wrapping the day up. Thanks for the icing on the cake. Always appreciate your help.
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,219
Members
452,620
Latest member
dsubash

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