How can I set a variable with text?

Basically, I want to set a variable. When a cell has text in it (“Yes” or “No” in this case), I want to set a variable for that row (2 for “Yes”, 0 for “No”).

Edit: I had a second problem here but I managed to fix it.

Hi

It is not easy to answer this question because you do not give the context of use of this variable: in a table cell, in a formula, a program (eg basic), etc.

You do not indicated your experience of a spreadsheet. I could therefore respond by what may seem to you the obvious. Sorry if this is the case.

If the cell containing the text is A1 you can, for example in B1 enter a formula: =IF(A1="Yes";2;0)

Please note, this formula will return 2 only if A1 contains “Yes”. “yes” will return 0, as well as cells containing “No” or any text and empty cells.

You can treat this case with a more complete formula: =IF(A1="Yes";2;IF(A1="No";0;""))

It is also possible to create named formulas (menu InsertNames) but it is a little more complex.

If you are beginner in the use of Calc I suggest you consult the documentation available here.

Regards