*強いテキスト* 以下のコードは正常に実行されますが、正と負の両方のセル値を同じものとして扱い、それに応じて色を付けるコードが必要です
元:
1) 0 ~ 4 および 0 ~ -4 = 緑色 2) 5 ~ 9 および -5 ~ -9 = オレンジ色
以下のコードは、正の値に対してのみ機能します
サブ changeTextColor()
GreenColor = RGB(0, 128, 0)
RedColor = RGB(255, 0, 0)
OrangeColor = RGB(255, 204, 0)
WhiteColor = RGB(255, 255, 255)
'Get number of rows in the specified column
RowsCount = Range("K2", Range("K2").End(xlDown)).Rows.Count
'Select cell
Range("K2").Select
'Loop the cells
For x = 1 To RowsCount
If ((ActiveCell.Value) <= 4) Then
ActiveCell.Interior.Color = GreenColor
ElseIf ((ActiveCell.Value) >= 5) And ((ActiveCell.Value) <= 9) Then
ActiveCell.Interior.Color = OrangeColor
ElseIf ((ActiveCell.Value) > 10) And ((ActiveCell.Value) <= 10000) Then
ActiveCell.Interior.Color = RedColor
End If
ActiveCell.Offset(1, 0).Select
Next
サブ終了