Hello,
I'm new to excel IF function, could someone please help me with this. I've been trying to figure out make a formula that i want it (IF FUNCTION), but no luck so far.
so this how i want it.
excel.jpg
Thank you
Hello,
I'm new to excel IF function, could someone please help me with this. I've been trying to figure out make a formula that i want it (IF FUNCTION), but no luck so far.
so this how i want it.
excel.jpg
Thank you
Do you want it to be John that's not married, or just whatever name is in column B?
You might need to provide a larger sample so we can see your desired results.
Try this in cell D5 and drag it down:
That will work if all you want is it to return M or NM based on the cell in the C column.![]()
=if(C5="Married","M","NM")
I believe you are trying to return if they are married to one another, so that might require a function other than if. Once again, we need a larger sample size to see what you are actually expecting as results.
Formula:
=IF(C5="Married","M","NM")
Trevor Shuttleworth - Retired Excel/VBA Consultant
I dream of a better world where chickens can cross the road without having their motives questioned
'Being unapologetic means never having to say you're sorry' John Cooper Clarke
Hi,
Thank you for replying
I tried to do like what you told me but every time I hit enter, it gives me an error like this
excel2.jpg
You may need to replace the commas with semi-colons:
=IF(C5="Married";"M";"NM")
Biff
Microsoft MVP Excel
Keep It Simple Stupid
Let's Go Pens. We Want The Cup.
Thank you so much.
I did
![]()
You're welcome. Thanks for the feedback!![]()
oh . oh . oh .
How about if I wanna do it like this ?
excel3.jpg
Try this
Formula:
=LOOKUP(8^5;SEARCH({"Married";"Not Married";"Divorced"};C5);{"M";"NM";"P"})
v B C D E 5 John Married M 6 Scott Not Married NM 7 Bobby Divorced P 8 Scott Divorced P
If you like my answer please click on * Add Reputation
Don't forget to mark threads as "Solved" if your problem has been resolved
"Nothing is so firmly believed as what we least know."
--Michel de Montaigne
Well, before you embark on writing a formula for a problem, do something that's called "planning".
That will save you and others a lot of time.
So, what options will there be?
- married (M)
- not married (NM)
- divorced (D)
- widowed (W)
Any more? Re-married, maybe? After collecting all the options, it's time to assess which technique to use. With a lot of options, an IF statement can become quite long and hard to maintain, for example with the Name in A1, the married status in B2, the above options in an IF Statement would be
I've used multiple lines and indentation to draw attention to how the IF statements are nested.![]()
=if(B2="Married","M", if(B2="Not Married","NM", if(B2="Divorced","D", if(B2="Widowed","W","Other") ) ) )
With so many options, you may as well write a small table on a different sheet with the married status in column A and the abbreviation in column B. Then you can use a simple Vlookup formula to retrieve the abbreviation:
To catch errors, wrap it in IFError![]()
=vlookup(B2,Sheet2!$A$1:$B:$4,2,false)
If you put the lookup table into an Excel object with Insert > table, you can add more rows to the lookup table and the lookup formulas will not need to be changed when new marriage status values are added to the table.![]()
=iferror(vlookup(B2,Sheet2!$A$1:$B:$4,2,false),"other")
cheers, teylyn![]()
=VLOOKUP(B2,MarriedStatus[#All],2,FALSE)
PS: remember to swap out the commas in the formulas for semicolons if that is what your region uses in Excel.
Last edited by teylyn; 08-13-2016 at 07:53 PM.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks