Link to home
Start Free TrialLog in
Avatar of Chris Michalczuk
Chris MichalczukFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Excel 2016 writing and applying a conditional formula to a cell

I have a problem where I want to apply a different formula based on the contents of another cell
cell     output     returns
C2      D2=E2      TRUE or False

based on the result I want to apply a concatenation of cells

example

=IF(C2 = TRUE then apply the formular D2 = CONCATENATE( "R-",S2," - ",T2)
=IF(C2 = FALSE then apply the formular D2 = CONCATENATE( S2," - ",T2)


also I may need to apply a third condition to the values in C2 ?
ExcelFormula.xlsx
Avatar of Subodh Tiwari (Neeraj)
Subodh Tiwari (Neeraj)
Flag of India image

Maybe this...
In D2
=IF(C2,CONCATENATE( "R-",S2," - ",T2),CONCATENATE( S2," - ",T2))

Open in new window

Avatar of Chris Michalczuk

ASKER

Hi Subodh great answer as saved me a lot of time. However got a related question to the condition

At moment I have TRUE , FALSE for cell C2 ie  (C2 = S2=T2)
How do I add a 3RD CONDITION TO ACT ON AND RETURN THE ANSWER AS "a", "b", "c") FOR EXAMPLE

IS THIS c2 = (s2=t2, ELSE s2=p2, "a", "b", "c")
I don't think I understand your latest requirement.
BTW see if this is what you are trying to achieve...
In C2
=IF(S2=T2,"a",IF(S2=P2,"b","c"))

Open in new window


The above formula means, if S2=T2, formula will return "a" in formula cell or if S2=P2, the formula will return "b" in the formula cell and if both the conditions are not met, the formula will return "c" in the formula cell.
Subodh

Cell A      CELL B      RETURN
                test1              a
same      same              b
run1      different      c


these are the 3 cases I need to apply the formulas too see attached sheet sheet 2
ExcelFormula.xlsx
Okay try the below formula in D2 in the sample file and copy it down and then compare the output returned by the formula with the values in col. C. See if you get the same output as in col. C.

In D2
=IF(COUNTBLANK(A2:B2)=1,"a",IF(A2=B2,"b",IF(A2<>B2,"c","")))

Open in new window

Or better use this formula, that will take care if both the columns are empty..

=IF(A2&B2="","",IF(COUNTBLANK(A2:B2)=1,"a",IF(A2=B2,"b","c")))

Open in new window

Perfect

=IF(COUNTBLANK(A2:B2)=1,"a",IF(A2=B2,"b",IF(A2<>B2,"c","")))

now I need to apply this to the original question where you gave the answer

=IF(C2,CONCATENATE( "R-",S2," - ",T2),CONCATENATE( S2," - ",T2))

ie
IF(C2 = "a" , concatenate
IF(C2 = "b" , concatenate
IF(C2 = "c" , concatenate
ASKER CERTIFIED SOLUTION
Avatar of Subodh Tiwari (Neeraj)
Subodh Tiwari (Neeraj)
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
What a star - thank you for your help has saved me hours of time
You're welcome Chris! Glad to help.
Thanks for the feedback.