I've found a manual way to merge cells with formatting using the following several steps and formulas:
Youtube video example below:
And the Sheet2 here:
How to Merge cells horizontally with formatting in Google Sheets?
Conditional formatting column E (range E1:E33):
=IFS(AND(C1="",D1=""),"$",AND(C1<>"",D1=""),C1&"#",AND(C1="",D1<>""),D1&"*")
Text is exactly:
$
—> set Background color to White
Text contains:
#
—> set Background color to Red
Text contains:
*
—> set Background color to Green
Conditional formatting column F (range F1:F33):
=RIGHT(E1:E,1)="$"
—> set Background color to White
=RIGHT(E1:E,1)="#"
—> set Background color to Red
=RIGHT(E1:E,1)="*"
—> set Background color to Green
Delete "$", "#" and "*" in range F1:F33.
My question is:
How to make the process simpler and automated with a script? possibly with less steps?
Thanks a lot for your help and ideas!
EDIT:
Answering the suggested answer
How my question is different?
If my understanding it correct, the .mergeAcross() action works to merge cells to keep only the top left content of the left column cell (column A) into the output cell (the merged result).
In my case that would not work to merge 2 cells and keep the content of the right column cell into the merged result.
For example:
When A1 is blank (A1="") and B1 is not blank (B1<>"" / B1=1) have the output cell return B1 content (C1 return "1").
Also it doesn't seem to address the formatting needed criteria.
For example:
If A1="", and B1<>"" / B1=1, and B1 cell background is Red, return B1 content and formatting in the output cell (C1 return 1 with red as cell background color).
But thanks a lot for the suggestion about .mergeAcross() action. I didn't know about it and it sure is valuable to know.
