Conditional formatting of PowerPoint-table

conditional formattingmicrosoft-powerpointmicrosoft-powerpoint-2013

Related to this question, I wonder if there is any way to apply conditional formatting to a table in PowerPoint, without importing an Excel-table. E.g. to change the background colour of a cell in the table depending on the value in it.

Best Answer

Yes, but only via code/macro of some sort. You'd iterate through the .Cell collection of the table, check to see that each cell has text and if so, if the value of the text converted to numeric is < 0, then set the cell's .Shape fill to whatever you like. Pass a reference to the table to this, for example:

Sub FormatTheTable(oTbl As Table)
    Dim x As Long
    Dim y As Long

    With oTbl
    For x = 1 To .Rows.Count
    For y = 1 To .Columns.Count
        If .Cell(x, y).Shape.TextFrame.HasText Then
        If CDbl(.Cell(x, y).Shape.TextFrame.TextRange.Text) < 0 Then
            .Cell(x, y).Shape.Fill.ForeColor.RGB = RGB(255, 0, 0)
        End If
        End If
    Next    ' Column
    Next    ' Row
    End With    ' otbl
End Sub
Related Question