셀 내의 숫자의 크기에 따라서 상대적인 색깔 찰하기
Sub cellPaint()
Dim max As Integer
Dim rows As Integer
Dim cols As Integer
Dim colors As Integer
rows = 31
cols = 12
max = 0
For i = 4 To rows
For j = 6 To cols
If max < Cells(i, j) Then
max = Cells(i, j)
End If
Next j
Next i
For i = 4 To rows
For j = 6 To cols
Select Case Int(Cells(i, j) / (max / 6))
Case 0
If Cells(i, j) > 0 Then
colors = 19
Else
colors = 2
End If
Case 1
colors = 15
Case 2
colors = 48
Case 3
colors = 16
Case 4
colors = 56
Case Is > 4
colors = 1
End Select
Cells(i, j).Interior.ColorIndex = colors
Next j
Next i
End Sub
No comments:
Post a Comment