conditional formatting with an if statement

dmills335

New Member
Joined
Jun 14, 2018
Messages
21
hello,

i am trying to use conditional formatting to format a cell with text based on the value of another cell.
for example, if cell "A1" = "test" then cell "C5" = "result"

i am using the custom format to output "result" and a bodged together if statement to carry out the function =IF(A1<>"test","result",C5).
however, "result" overwrites the current value of a numeric cell with text; if that numeric cell has a negative number, "result" displays the text with a preceding "-".

any help with a more elegant if statement and the formatting of the negative text would be greatly appreciated.
 
dante,

"E";"E" works perfectly.
thank you very much.

please excuse my ignorance, but can you explain why that method works?
 
Upvote 0

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
dante,

"E";"E" works perfectly.
thank you very much.

please excuse my ignorance, but can you explain why that method works?



Custom Number Formats
If one of the built-in number formats does not display the data in the format that you require, you can create your own custom number format. You can create these custom number formats by modifying the built-in formats or by combining the formatting symbols into your own combination.


Before you create your own custom number format, you need to be aware of a few simple rules governing the syntax for number formats:
Each format that you create can have up to three sections for numbers and a fourth section for text.

<code class="" style="box-sizing: inherit; font-family: Consolas, "Courier New", Courier, monospace; font-size: 1em;">< POSITIVE > ; < NEGATIVE > ; < ZERO > ; < TEXT ></code>
<negative><zero><text>The first section is the format for positive numbers, the second for negative numbers, and the third for zero values.
These sections are separated by semicolons.
If you have only one section, all numbers (positive, negative, and zero) are formatted with that format.

Source: https://support.microsoft.com/en-my...stand-settings-in-the-format-cells-dialog-box</text></zero></negative>
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,098
Messages
6,128,812
Members
449,468
Latest member
AGreen17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top