Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

new to excel, trying to figuring out how to do an if statement

this question is linked to Formula to remove every middle name in a cell in Excel.

I basically want to make an if else statement in excel. So the IFchecks if the cell is equal to "Gian" OR"Pier", if the condition is confirmed the formula proceeds to use this other formula

=IFERROR(LEFT(A2,FIND(" ",A2)-1),A2)

Sorry guys idk how to do it in an excel way. I can show you in for example in a Java or C way.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

if(A2=="Pier" || A2=="Gian")
       =IFERROR(LEFT(A2,FIND(" ",A2)-1),A2) \\the excel formula that deletes every second/third name if the cell

enter image description here

if formula in excel that checks a condition and if its verified it proceeds to use another excel formula

>Solution :

You could try the following as per your Excel Versions

enter image description here


• Formula used in cell B2

=IF(OR(TEXTBEFORE(A2&" "," ")={"Pier","Gian"}),A2,TEXTBEFORE(A2&" "," "))

Or, in cell C2

=IF(OR(LEFT(A2&" ",FIND(" ",A2&" ")-1)={"Pier","Gian"}),A2,LEFT(A2&" ",FIND(" ",A2&" ")-1))

Just adding the use of LET() which makes it simpler,

enter image description here


• Formula used in cell B2

=LET(x,TEXTBEFORE(A2&" "," "),IF(OR(x={"Pier","Gian"}),A2,x))

Or, Formula used in cell C2

=LET(x,LEFT(A2&" ",FIND(" ",A2&" ")-1),IF(OR(x={"Pier","Gian"}),A2,x))

Using MAP() to Spill as one dynamic array formula but the logic remains same.

enter image description here


• Formula used in cell D2

=MAP(A2:A6,LAMBDA(m,
LET(x,TEXTBEFORE(m&" "," "),
IF(OR(x={"Pier","Gian"}),m,x))))

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading