but it would be nice if it works for .Activesheet only instead of the entire file.
Code: Select all
sub set_tab_colour_by_cell_value()
all_sheets = ThisComponent.Sheets ' get all sheets
' iterate over sheets, looks like in the weird Basic it's safer to do it this way
for i = all_sheets.getCount()-1 To 0 Step -1
a_sheet = all_sheets.getByIndex(i) ' get a sheet
cell_location = "A1" ' cell value to be used to set the tab colour
cell_value = a_sheet.getCellRangeByName(cell_location).Value ' get the cell value
new_colour = -1 ' -1 is the default colour
if cell_value < 0 then
new_colour = RGB(255, 0, 0) ' red
elseif cell_value > 0 then
new_colour = RGB(0, 255, 0) ' green
endif
a_sheet.tabcolor = new_colour ' set the tab colour
next
end sub
I found this for VBA, but of course it wont work for LO
Code: Select all
Private Sub Worksheet_Change(ByVal Target As Range)
If Range("H11").Value = "Order Sent" Then
Me.Tab.Color = RGB(255, 192, 0)
ElseIf Range("H11").Value = "Order Confirmed" Then
Me.Tab.Color = RGB(16, 124, 16)
Else
Me.Tab.Color = RGB(212, 46, 18)
End If
End Sub
yes manual tab color change is possible, by why not be creative, right?
Debian 12 with LO 7.5