Forum Discussion
Richie_M
Jul 30, 2019Copper Contributor
If a cell contains specific text, return this specific text otherwise leave blank
Hi,
I am using a pre-made excel spreadsheet for time sheets at work. I work 32 hours a week with Monday off. I am trying to insert an IF function that if the Day is 'Monday', return 'Non-Work Day'.
I am currently using:
=IF(B12="Monday","Non-Work Day," ")
however all i get is a blank cell, even if the day is Monday.
I believe the problem is : the date column sets the day, so 1 July 2019 in cell C11 automatically changes the day in cell B11 to Monday, so the value in B11 is still equal to 1 July 2019, not Monday. (formula in B11 is '=c11)
Is there a way to get excel to read the output of 'Monday' instead of the input of '=c11' so I can match to 'Monday'?
Many thanks
I'm sorry but i see no limitations which could prevent to use nested IF. The only point it is a bit less flexible compare to nested If equivalents.
But what to use depends on goals, in some cases quick hardcording works quite fine.
If use formatting nested if becomes much more clear and editable. Like this
=IF(ISNUMBER(SEARCH("Sales", B3,1)),"Sales",
IF(ISNUMBER(SEARCH("Arch", B3,1)),"Architecture",
IF(ISNUMBER(SEARCH("Land", B3,1)),"Land",
IF(ISNUMBER(SEARCH("All", B3,1)),"All",
IF(ISNUMBER(SEARCH("Contracts", B3,1)),"Contracts",
IF(ISNUMBER(SEARCH("Construction", B3,1)),"Construction",
"No Match"
))))))
If instead of hardcoded strings use references nested IF becomes more flexible. And if add some extra references (nested if) for future strings to find it becomes even more flexible.
=IF(ISNUMBER(SEARCH($F$1,B3,1)),$G$1, IF(ISNUMBER(SEARCH($F$2,B3,1)),$G$2, IF(ISNUMBER(SEARCH($F$3,B3,1)),$G$3, IF(ISNUMBER(SEARCH($F$4,B3,1)),$G$4, IF(ISNUMBER(SEARCH($F$5,B3,1)),$G$5, IF(ISNUMBER(SEARCH($F$6,B3,1)),$G$6, IF(ISNUMBER(SEARCH($F$7,B3,1)),$G$7, IF(ISNUMBER(SEARCH($F$8,B3,1)),$G$8, IF(ISNUMBER(SEARCH($F$9,B3,1)),$G$9, "No Match" )))))))))
I don't vote for nested IF, i would like to say where is no limitations here. What to use that's concrete person choice.
2 Replies
Sort By
Hi
The setup is not clear to me. However to evaluate the Weekday of any date you can use one of 2 functions:
- Weekday function >> Returns a number from 1-7 (or 0 to 6)
- TEXT function >> Returns text based upon the formatting you specify in the second argument.
In your case , if you are evaluating the date in cell B12, then your function will be
=IF(TEXT(B12,"dddd")="Monday","Non Working Day","")
Your other issue of a cell referencing a wrong one, I need to check and audit your worksheet to fix it.
Hope that Helps
Nabil Mourad
- Richie_MCopper Contributor
Thank you, that formula works.
That was my only issue, I must have explained my issue poorly, thank you for your help.