[Solved] Choose cell background dynamically

Discuss the spreadsheet application
Post Reply
Calab
Posts: 6
Joined: Wed Mar 13, 2024 12:27 am

[Solved] Choose cell background dynamically

Post by Calab »

I have a small sheet with a fair number of lines on it. When I enter a name in the first column, I would like that row to automatically fill the background color. If I entered a name that was already there, I would want to see the same color used as before. If the name has not been added to the column before, I would want a new color to be picked.

I know I can use conditional formatting, but entering a new format every time I entered a new name will get tedious quickly.

Image

Maybe I could use a formula to sum all the ascii values of the letters in a name and use that for the color number?

Is this possible?
Last edited by Hagar Delest on Mon Sep 02, 2024 8:01 am, edited 1 time in total.
OpenOffice 4.1.15 on Windows 11
User avatar
Zizi64
Volunteer
Posts: 11505
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Choose cell background dynamically?

Post by Zizi64 »

Just create some colorized Cell style and apply them by the Conditional Format feature.
Tibor Kovacs, Hungary; LO7.5.8/25.8.5.2 /Win7-10-11 x64Prof.
PortableApps: LO3.3.0-25.8.5.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Lupp
Volunteer
Posts: 3756
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Choose cell background dynamically?

Post by Lupp »

Calab wrote: Sun Sep 01, 2024 4:07 pm I know I can use conditional formatting, but entering a new format every time I entered a new name will get tedious quickly.

Maybe I could use a formula to sum all the ascii values of the letters in a name and use that for the color number?

Is this possible?
Many things are possible but not advisable.
Concerning Calc complicated and unusual things may often need a lot of custom programming.

Concerning the idea with a calculated color code I would expect strange and unwanted effects. To do this without custom code shouldn't be possible anyway.

Generally: In next to every case it is preferrable to attach an example file instead of an image. The exceptional cases are thode where a specific issue with an element of the view is addressed.
On Windows 10: LibreOffice 25.8.4 and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
Calab
Posts: 6
Joined: Wed Mar 13, 2024 12:27 am

Re: Choose cell background dynamically?

Post by Calab »

Thanks folks... This is more complicated than it's worth. I'll just do the formatting manually as I go. There isn't a lot of data anyhow.
OpenOffice 4.1.15 on Windows 11
User avatar
Lupp
Volunteer
Posts: 3756
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Choose cell background dynamically?

Post by Lupp »

Calab wrote: Sun Sep 01, 2024 9:58 pm Thanks folks... This is more complicated than it's worth. I'll just do the formatting manually as I go. There isn't a lot of data anyhow.
OK.
However, this is not a solution to the question.
In addition the usage of colors for the described task or a similar one is not advisable. There are simply too few colors which the human eye (yours? mine? somebody elses?) can reliably distinguish - and the related abilities differ from person to person and depend on the used screen.
Anyway somebody coming to this topic based on the subject might be interested in a solution for the problem in the sense of
"How can visual attributes be applied without defining lots of conditionally applied styles?"
And/Or
"How can such attributes be actually set for cells automatically depending on a condition instead of just overlaying them by conditional formatting?"
For a wide range of roughly similar question, the answer is partly "You need user code."
My preferred extension would be "...and use templates."

How to do so is exemplified in the attached Calc doument.
It may not quite easy to apply it to a different case, and the contaioned code doesn:t come with a guarantee of any kind, nor is it really flexible.

Also: The .Type property of SearchDescriptor objects seems to be not documented. I used it based on a guess, and got what I wanted.
On Windows 10: LibreOffice 25.8.4 and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
Post Reply