Tell me, is it possible to somehow set programmatically in excel so that if the cell had a value greater than 0,4 , then the cell data color would be green, to -0,3 - gray, and even less - red?
|
2 answers
Select the desired cells and on the main tab click Условное форматирование , then Управление правилами .
Click Создать правило . Next, select Форматировать только ячейки, которые содержат , then set the Значение ячейки , больше 0,4 , click the Формат button, select red. Further ОК , and again ОК .
In the same way create two more rules, but with other conditions and color.
It should end up with something like this:
- And if I have such a table, what is the number for me to mark each? - nnnn
- @nnnn first select all the desired cells, then click
Условное форматирование, create rules, etc. they will be applied to all selected cells. - Vladimir Gamalyan - @ Vladimir Gamalian This is not what I understood, but the question is now different. Suppose I have a huge table of such number and until I select all the cells it will take 2 hours, is there any option to set the lower threshold and from this threshold and above there will be 1 color? - nnnn
- @nnnn in the same place where rules are created (in the conditional formatting rule manager), you can specify cells in the
Применяются кcolumn in the form of an excel range (for example=$B$1:$L$18). - Vladimir Gamalyan
|
You can set a macro color (set the area, where r is the number of rows, c is the number of columns):
Sub FillCell() Dim WB As Workbook Set WB = ActiveWorkbook Dim WS As Worksheet Set WS = WB.ActiveSheet Dim Cell As Object Dim r, c As Integer ' Row count r = 5 ' Column count c = 4 For i = 1 To r For j = 1 To c Set Cell = WS.Cells(i, j) If (Cell <> "") And (IsNumeric(Cell)) Then With Cell.Interior .Pattern = xlSolid .PatternColorIndex = xlAutomatic Select Case Cell Case Is > 0.4 .Color = 65280 Case Is > -0.3 <= 0.4 .Color = 255 Case Else .Color = 12632256 End Select .TintAndShade = 0 .PatternTintAndShade = 0 End With End If Next j Next i End Sub Result:
|

