Is there anyway to format negative numbers in red in a table in Powerpoint 2010?
I have tables of data and I want the negative numbers to show up in red (similar to what you would do in Excel). Does PowerPoint have this capability?
This macro will format the named table on the active slide to have negative numbers in red and within parentheses. I have not found a way to format the table manually.
Sub FormatTheTable()
Dim x As Long
Dim y As Long
With ActivePresentation.Slides(4).Shapes("Table 540").Table ' Table 540 is the name of the shape/table
For x = 2 To .Rows.Count 'Starts on the second row to ignore titles
For y = 2 To .Columns.Count 'Starts on the second column to ignore titles
If .Cell(x, y).Shape.TextFrame.HasText Then 'Checks that the cell has text
If CDbl(Val(.Cell(x, y).Shape.TextFrame.TextRange.Text)) < 0 Then 'converts text to a double and evaluates it to be less than zero
.Cell(x, y).Shape.TextFrame.TextRange.Text = CDbl(Val(.Cell(x, y).Shape.TextFrame.TextRange.Text)) * -1 'multiply by negative 1 to remoe the negative sign
.Cell(x, y).Shape.TextFrame.TextRange.Font.Color = RGB(255, 0, 0) 'Change font color to red
.Cell(x, y).Shape.TextFrame.TextRange.Font.Bold = True 'Makes the font bold
.Cell(x, y).Shape.TextFrame.TextRange.Text = "(" & .Cell(x, y).Shape.TextFrame.TextRange.Text & ")" 'Adds parentheses
Else
.Cell(x, y).Shape.TextFrame.TextRange.Font.Color = RGB(0, 0, 0) ' makes the non-negative numbers font color black
.Cell(x, y).Shape.TextFrame.TextRange.Font.Bold = True 'Makes the font bold
End If
End If
Next ' Column
Next ' Row
End With ' otbl
End Sub