Below is a small snippet of VBA code for setting cell background color and cell text color based on RGB values (R – red color, 0 to 255, B – blue color, 0 to 255, and G – green color, 0 to 255) helps make cells text readable, based on background color eg avoids dark text on say red background cells.. especially for gantt chart makers.. you know who you are… 🙂

Brightness = ((0.241 * (R * R)) + (0.691 * (G * G)) + (0.068 * (B * B)))
Worksheets(1).Cells(row, col).Interior.Color = RGB(R, G, B)
If Brightness < 16900 Then
Worksheets(1).Cells(row, col).Font.Color = RGB(255, 255, 255)
Else
Worksheets(1).Cells(row, col).Font.Color = RGB(0, 0, 0)
End If

Note: row is the cell row number, and col is the cell column number.