1

I am trying to write a statement which will read the content of the adjacent cells and select a value depending on the results to punctuate a paragraph. Just like the below sentence is laid out.

Statement 1, Statement 2, Statement 3.

A comma is included if the next statement has content. A full stop is included if the next statement does not have content. Nothing is included if the next and previous statements do not have content. I have used the formula below, but the bit that's supposed to add the full stop is returning FALSE:

=IF(A1<>"",IF(C1<>"",", "),IF(A1<>"",IF(C1="",". "),IF(A1="",IF(C1="",""))))

What have I done wrong?

2
  • 1
    you're missing several [value_if_false]. If your if-tests go this way and no [value_if_false] is defined, the formula will return "false" as a result Commented Jun 4, 2019 at 7:41
  • Thanks @Jo.lass but I'm not sure I understand what you mean. It shouldn't be returning a false value anyway, it should find this part to be true? IF(A1<>"",IF(C1="",". ") Commented Jun 4, 2019 at 7:48

4 Answers 4

3

I believe you have overcomplicated your formula. For example you test up to 3 times if A1 is blank

Are you trying to achieve this ?

=IF(A1<>"",IF(C1<>"","; ",""),IF(C1="",". ",""))
  • if A1 is not blank and C1 is not blank = ;
  • if A1 is not blank and C1 is blank = nothing
  • if A1 is blank and C1 is blank = .
  • if A1 is blank and C1 is not blank = nothing
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks @Jo.lass, that's almost right. I'm trying to achieve: if A1 is not blank and C1 is not blank = , if A1 is not blank and C1 is blank = . if A1 is blank and C1 is blank = nothing
Based on your formula I've just tried this which works :-) =IF(A1<>"",IF(C1<>"",", ",". "),IF(C1="","","")) Thanks again for your help!
Yes, wasn't sure which one is right ;) thanks for the feedback
Curses, foiled again - I took too long drawing out a flowchart of the logic tree
3

The IF statement has this format: =IF(<Statement>, <Value_If_True>, <Value_If_False>)

If we break your code down in the same way, we get this:

    =IF(<Statement1>, IF_TRUE1(<Statement2>, <Value_If_True2>), IF_FALSE1(<Statement3>, IF_TRUE3(<Statement4>, <Value_If_True4>), IF_FALSE3(<Statement5>, IF_TRUE5(<Statement6>, <Value_If_True6>))))

The missing <Value_If_False> will return FALSE by default.

Now, that might be a bit hard to read, so here's another layout: Flow Chart of If Statement Logic

Hopefully you can see all of the duplicate "question" nodes there - and also that the "." is impossible to reach, because it requires that A1<>"" is FALSE, and also TRUE.

Rewriting your code, there is still 1 "missing" terminator:

=IF(A1="", IF(C1="", "", FALSE), IF(C1="", ".", ", "))

(Or, if you want to be really fancy, use a CHOOSE statement:)

=CHOOSE(1+(A1="")+2*(C1=""), ", ", FALSE, ".", "")

1 Comment

Damn, that's a great explanation of the original issue - very visual +1
0

This part of your formula seems redundant as it is already captured in the initial logical arguments:

IF(A1<>"",IF(C1="",". "),IF(A1="",IF(C1="","")))

I might not understand your objective entirely, but this should do the trick: I'm assuming statements here are defined by inputs into columns A,B & C and column A has to be filled first.

=IF(A1="","",IF(AND(B1="",C1=""),". ",", "))

If I'm way off, do share your table/sheet structure with desired results.

Comments

0

Ok, had a go at this just to see:

=IF(AND(A1="",C1=""),"",IF(AND(A1<>"",C1<>""),A1&";"&C1,A1&C1&"."))

enter image description here

And if both are not blank, then they should be separated by ";" and finished with "." ...

=IF(AND(A1="",C1=""),"",IF(AND(A1<>"",C1<>""),A1&";"&C1&".",A1&C1&"."))

See:

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.