In my sheet, I want to automatically take negative numbers, change the color to red, and remove the '-' character. The number in a cell can fluctuate between positive and negative, based on data in other cells eg...
A1 = "some number"
A2 = "some number"
A3 = A1 + A2 (number should be red if value is a negative, and '-'
should be stripped off. Otherwise number should be black.
I've written an apps script that should do this
function negativesToRed(num) {
if (num < 0) {
var newNum = (num * -1).toString();
var redNum = newNum.fontcolor("red");
}
return redNum;
}
but when I use it, it returns...
<font color="red">605</font>
...in the cell.
NOTE: A3 needs to turn red when data inputted in A1 or A2 changes it to a negative. onEdit() will only work if user manually changes A3 to a negative number. AND if the value in A3 is used elsewhere, it needs to be treated as a negative number (removing '-' is just for display).
Is there anyway to get this to work?