A Conditional Format to change the background color but keep the Date format

2

1

I have and OpenOffice Calc document that has a "table" with Text, Numeric and Date columns. I have a conditional format making every odd row have a different background color so it will be easier to read.

The problem is that the rows which are affected by the conditional format will loose it's other format. In this case the date. If I put a date format in the conditional style then the Numeric cells will become a date...

Is this fixable and if so How?

Andis59

Posted 2015-07-08T11:29:26.357

Reputation: 133

Answers

1

Select the range and run this macro:

Sub Main
    Dim oCurrentSelection As Variant
    Dim oRows As Variant
    Const nCellBackColor = 15132415 REM # "Blue gray"
    Dim i As Long
    oCurrentSelection = ThisComponent.getCurrentSelection()
    If oCurrentSelection.supportsService("com.sun.star.table.CellRange") Then
        oRows = oCurrentSelection.getRows()
        For i = 0 To oRows.getCount()-1 Step 2
            oRows.getByIndex(i).setPropertyValue("CellBackColor", nCellBackColor)
        Next i
    EndIf
End Sub

duDE

Posted 2015-07-08T11:29:26.357

Reputation: 14 097

1Very nice - works for LibreOffice Calc, too! – tohuwawohu – 2015-07-08T18:28:34.003

0

You could try to use an extension rather than conditional formatting, this shouldn't change the formatting of the cells (other than the background)

http://extensions.services.openoffice.org/en/project/Color2Rows

lon0

Posted 2015-07-08T11:29:26.357

Reputation: 36

Since the extension hasn't been updated since 2009, I didn't try it. Maybe it works... – Andis59 – 2015-07-08T12:29:16.413