Reputation: 11
I use the following formula in an excel spreadsheet to enter an x or n in a cell based on the date range entered in to adjacent cells on the left side of my spreadsheet.
=IF(AND(Q$5>=$G13,Q$5<=$H13)=TRUE,IF($F13="N","N",IF(AND(Q$5>=$G13,Q$5<=$H13)=TRUE,"X","")),"")
It looks at column G and H and compares it to column L through T and then places an x in the matching cell. This formula works great, however I would like to add another argument to the formula to place an x in a cell when an "S" is entered in a cell adjacent to the date range otherwise it should be blank. Basically toggling Saturday on or off. Currently I have the same formula for each cell for column M - T. I was trying to write a different formula for column R (SAT), unless there is a way for it to be the same. The current formula works without the Saturday option, if the date range cells in the revised formula are blank the word false is returned. How can a formula be written to leave the cell blank if no information is in the date range.
This revised formula works except a "false" value is returned if the date columns are blank.
=IF(AND(R$5>=$G10,R$5<=$H10)=TRUE,IF($E10="S","X",IF(AND(R$5>=$G10,R$5<=$H10)=TRUE,IF($F10="N","N",IF(AND(R$5>=$G10,R$5<=$H10)=TRUE,"","X")),"")))
My question is can a formula be written to place an x in a cell based on the letter S entered into a cell and leave it blank if the letter S is not.
Upvotes: 0
Views: 69
Reputation: 33175
=REPT(IF($F13="N","N","X"),AND(AND(L$5>=$G13,L$5<=$H13),NOT(AND($E13<>"S",WEEKDAY(L$5)=7))))
What makes it so cumbersome is that you have three possibilities; X, N, or blank. The REPT function will repeat a string a certain number of times. By using that to product X or N, now I'm only down to two possibilities; True or False. I made a truth table to find the right formula. Also, true = 1 and false = 0 and that's why REPT works.
Upvotes: 1