Set cell colour to specific colour value in another cell

I have a spreadsheet of tapestry wool thread numbers and their hex colours. I would like to add another column in which the cells would be coloured with the colour specified in the colour cell. I also have the RGB values which could be used if that is simpler. I’m using LO 6.1.2.1 (x64). I can’t find a function to set a cell colour directly from a colour value.

Any ideas?

Jim

I got it done. I made a tiny macro by taking bits of other people’s code. In case it is of use to anyone else, here it is.

sub setcolor

mycell = thisComponent.getcurrentselection() 'C1 - target cell whose color would be changed

mycelladdr = mycell.getcelladdress()

r1 = mycell.getspreadsheet().getcellbyposition(mycelladdr.column-3,mycelladdr.row).value 'red value is in 3rd column to the left

g1 = mycell.getspreadsheet().getcellbyposition(mycelladdr.column-2,mycelladdr.row).value 'green value is in 2nd column to the left

b1 = mycell.getspreadsheet().getcellbyposition(mycelladdr.column-1,mycelladdr.row).value 'blue calue is in 1st coolumn to the left

mycell.CellBackColor = rgb(r1,g1,b1)

End Sub

Then I just highlight the cell to the right of the three cells containing the RBG values and run the macro.

Cheers,

Jim