If then statements involving 2 different cells

If one cell on my Numbers spreadsheet says "Debit" can I turn a positive number in another cell into a negative number? And, alternatively, if that same cell says "Credit" then the number stays positive? What is the correct formula syntax to do that?

MacBook Pro 13″, macOS 15.1

Posted on Jan 3, 2025 4:14 AM

Reply
Question marked as Top-ranking reply

Posted on Jan 3, 2025 7:10 AM

macshamrock wrote:

can I turn a positive number in another cell into a negative number


In spreadsheets like Numbers you generally cannot use a formula to change a value in another cell. Formulas generally place their results in their own cell.


So you can read the original number in one cell and "Debit" vs "Credit" in another cell and place the result in a third cell.



In D2 of the example, filled down:


=B2*SWITCH(C2,"Debit",−1,"Credit",1)


More on SWITCH here:


SWITCH - Apple Support


SG



8 replies
Question marked as Top-ranking reply

Jan 3, 2025 7:10 AM in response to macshamrock

macshamrock wrote:

can I turn a positive number in another cell into a negative number


In spreadsheets like Numbers you generally cannot use a formula to change a value in another cell. Formulas generally place their results in their own cell.


So you can read the original number in one cell and "Debit" vs "Credit" in another cell and place the result in a third cell.



In D2 of the example, filled down:


=B2*SWITCH(C2,"Debit",−1,"Credit",1)


More on SWITCH here:


SWITCH - Apple Support


SG



Jan 4, 2025 9:22 AM in response to macshamrock

macshamrock wrote:

Can you put this Boolean into an example for me?


Just a heads up that that's an "Excelsy" thing to do that doesn't translate all that well to Numbers.


In Numbers you're going to get a blue triangle with the message "The formula uses a Boolean in place of a Number," something like this:



I haven't found a way to make the blue triangles go away.


If you don't mind the triangles then by means use that approach.


If you do mind them, then use a function like SWITCH (or IF) to give you actual number values to be used in further calculations.


SG



Jan 5, 2025 2:41 PM in response to macshamrock

How about red = debit, black = anything else?



Formula in D2 =IF(C2="debit",B2,"")

Fill down to complete the column


Select the corresponding range of cells in column B then make the conditional highlighting rule shown in the screenshot to make a rule for all of them at once. If you do it all at once like that, the rule for B2 will refer to D2, B3 to D3, etc.


Hide column D


If you are doing math on the cells, they won't be negative. I don't know what you will be doing with them next so I don't know what all to suggest for your downstream formulas. Subtraction, SUMIF, or something else.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

If then statements involving 2 different cells

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.