Multiple font colors in same cell

I have a cell that I want to have to different values from two different cells:

Code: =P6 & "; " & P8
Display: 128; 64

This works for me, but I also want the first value (P6, ‘128’) to display in red and the second value (P8, ‘64’) to display as blue. Is there a way to do this? I’m not looking for conditional formatting. I always want the first value to display in font color red and the second value to display in font color blue.

As far as I know (LO 7.1.8.1), it is not possible to add different text colors in a cell with formula.
As a workaround, you can use adjacent columns with formulas =P6 and ="; "&P8 (this last one right aligned).

You should consider the reason why you want this, there may be another way to emphasise the origin of the figures.

The workaround that LeroyG suggests is way better than that what I suggest below, which I did only as a puzzle.

You can draw a rectangle that fits inside the cell boundaries, give it a gradient fill, Linear, 90 degrees, Red, Blue, Transparency 50%. Adjust it so it covers the figures appropriately (I added some more spaces in the concatenation to allow for a reduced number of digits) then right-click it, Anchor > To cell (resize with cell), right-click again and Arrange > To background

2ColoursOneCell.ods (9.7 KB)

In @EarnestAl’s example if I copy C6 then paste it into an empty cell LO seems to try to paste the rectangle first, then if I press Enter LO tries to paste both the rectangle and the formula next, so (if set to) it asks if I want to over-paste and then has two rectangles on top of one another. I can even use the arrow keys to exit the cell and return to it before pressing Enter and get the same behavior. This seems buggy. Is there some sort of “I just pasted so this is now in a pasting mode ending with Enter…” feature I don’t know about? LO 7.3 on Ubuntu 20.

Press Enter to paste and clear clipboard: Open a spreadsheet document, choose Tools - Options - LibreOffice Calc - General.

1 Like

I paste both Background and formula together OK using Ctrl+V, icons, or menu Copy, menu paste.

I do get a problem because the objects are named the same and I cannot select the newly pasted background in Navigator because either Shape 1 selects the original cell. I have to Name the original cell background with a different name and then I can select the other cell’s pasted background using the name Shape 1.

Version: 7.3.1.3 (x64) / LibreOffice Community, CPU threads: 8; OS: Windows 10.0 Build 22000; UI render: Skia/Vulkan; VCL: win, Locale: en-NZ (en_NZ); UI: en-GB, Calc: CL, New user profile.

Anyway, I don’t recommend using a drawing object as a cell background. Cell Styles allow only a single colour.

1 Like

The data in a field (cell) must be atomic (indivisible). If for some internal reason you need to separate the data, then the data must be physically separated and placed in different cells for easy handling. You break this rule, thereby creating unnecessary complexity. Calc doesn’t know how to do this, and hopefully won’t, because it’s not necessary. No offense taken.