Nested if

Last Edited By Krjb Donovan
Last Updated: Mar 05, 2014 09:49 PM GMT

QuestionEdit

QUESTION: Need to compare two columns with the following conditions: B>A then Increase B<A then Decrease B=A then N/C B is empty then A is Delete A is empty then B is Add

ANSWER: Your question is having two interpretations. I am not sure whether you are asking solution by using Worksheet Function or VBA (Macro).

When reading your last two conditions (B is empty then A is Delete, A is empty then B is Add) I hope that you are looking for VBA solution.

If you are looking for VBA solution please try one of the otherexperts that claim expertise inVBA such as Bob Umlas, Tom Oligvy, Stuart Resnik, Jan Pieterse or Aiden Heritage. I know they have provided excellent solutions from my personal observations. Because as I stated in my profile, I am not proficient in VBA and therefore can not answer your vba question.


---------- FOLLOW-UP ----------

QUESTION: Is a nested if formula: Increase, Decrease, N/C, Delete, Add are just the names that I'm given depending on the scenario... If B is empty I will flagged with the name "delete" or "Add" if is not null.

ANSWER: I assume that your data is having the column headers, so your data starts from 2nd row.

Copy and paste the below formula in C2 cell =IF(AND(A2="",B2=""),"",IF(B2="","Delete A",IF(A2="","Add B",IF(B2>A2,"Increase",IF(B2<A2,"Decrease",IF(A2=B2,"N/C",""))))))

Drag the C2 cell formula to the remaining cells of Column C based on the A&B Column data.


---------- FOLLOW-UP ----------

QUESTION: Loods good but how can we ignore if on A or B we have a formula that is giving me an error #DIV/0!... can we incorporate the iserror into the above formula? where?

AnswerEdit

Try this...

=IF(OR(ISERROR(A2),ISERROR(B2)),"",IF(AND(A2="",B2=""),"",IF(B2="","Delete A",IF(A2="","Add B",IF(B2>A2,"Increase",IF(B2<A2,"Decrease",IF(A2=B2,"N/C","")))))))

Advertisement

©2024 eLuminary LLC. All rights reserved.