|
▼青空 さん:
>それぞれ違う色の背景色に
>変える方法を教えて頂ければ嬉しいです。
ColorIndexを変えることで色の設定はできます。
Sub test()
Dim myV As Long
Dim FR As Range
Dim i As Long, j As Long
Dim firstAddress As String
Dim myAry As Variant
'ここで色を設定していますので、お好きな色に
myAry = Array(3, 4, 6, 8, 7) '赤,黄緑,黄色,水色,ピンク
With Sheets("Sheet1")
.Cells.Interior.ColorIndex = xlNone
For i = 1 To 3
For j = 1 To 5
myV = WorksheetFunction.Large(.Range(.Cells(1, i), .Cells(10, i)), j)
Set FR = .Range(.Cells(1, i), .Cells(10, i)).Find(myV, LookIn:=xlValues)
If Not FR Is Nothing Then
firstAddress = FR.Address
Do
If FR.Interior.ColorIndex = xlNone Then
FR.Interior.ColorIndex = myAry(j - 1)
End If
Set FR = .Range(.Cells(1, i), .Cells(10, i)).FindNext(FR)
Loop While FR.Address <> firstAddress
End If
Next j
Next i
End With
End Sub
|
|