How do I set up automatic color change on negativ numbers in Excel
Precede the second portion of the number format with any of these
colors:
[BLACK], [BLUE], [CYAN], [GREEN], [MAGENTA], [RED], [WHITE], [YELLOW]
If you don't see one you need there, you can use any of the
InteriorColor numbers by using [COLOR n].
Use this VBA routine to figure out which color number corresponds to
which color. It will correspond to the row number.
Sub generateInteriorColors()
Dim i As Long
Dim wsh As Excel.Worksheet
Set wsh = Application.ActiveWorkbook.Worksheets.Add
On Error Resume Next
wsh.Name = "Interior Colors"
If Err.Number < 0 Then
Application.DisplayAlerts = False
wsh.Delete
Application.DisplayAlerts = True
Application.ActiveWorkbook.Worksheets("Interior
Colors").Activate
Exit Sub
End If
For i = 1 To 56
wsh.Cells(i, 1).Interior.ColorIndex = i
wsh.Cells(i, 2).NumberFormat = "$#,##0.00_);[Color " & i & "]
($#,##0.00)"
wsh.Cells(i, 2).Value = -i
Next i
End Sub
On Oct 17, 4:48 pm, Salle wrote:
|