|
こんにちは
入力する度にD列の値を全部調べ直すので非効率的ですよね。
Private Sub Worksheet_Change(ByVal Target As Range)
Dim mR As Range
Dim v
Dim i As Long
Dim x As Variant
If Target.Count > 1 Then Exit Sub
Set mR = Me.Range("D10", Me.Range("D10").End(xlDown))
If Intersect(Target, mR) Is Nothing Then Exit Sub
v = mR.Value
mR.Font.ColorIndex = 0
For i = 1 To UBound(v, 1)
Select Case Application.WorksheetFunction.Rank(v(i, 1), mR)
Case 1: x = 3
Case 2: x = 4
Case 3: x = 5
Case 4: x = 7
Case 5: x = 46
Case Else: x = 0
End Select
If x <> 0 Then
mR(i, 1).Font.ColorIndex = x
End If
Next
End Sub
|
|