I need to put 2 rows of data in a single cell, and color code them like so:
[endgoal]
So I decided to make a custom function with apps script, so far i've only been able to make the text be on top of each other, but can't for the life of me make it change color, so I was hoping to get some help here.
The function I made is the following (it's extremely simple but i'm a noob)
function pileUp(val1,val2) {
return val1+"\n"+val2
}
I've been searching here and found some people partially coloring cells, but none I tried worked for me, would appreciate any help.
P.D: The length of both bottom and top rows varies cell by cell, so anything that uses a range with a fixed amount of characters to color won't work
P.D.2: I do realize I didn't post my approach to actually changing the color, here it is:
function pileUp(val1,val2) {
var color="#b82f2f";
var format =SpreadsheetApp.newTextStyle()
.setForegroundColor(color)
.build();
var final=SpreadsheetApp
.newRichTextValue()
.setText('val1"\n"+val2')
.setTextStyle(0, 3, format);
return final }
I intended to see if this worked, then change the 3 in the penultimate line for a variable that was equal to the length of var1, but it didn't work.