以下链接问题的答案是回答您问题的开始。您需要使用 VBA 执行此操作,如下所示:
Do While i <= cols
Do While j <= rows
//set conditional formatting for range ij:i(j+1)
j = j + 2
Loop
Loop
我会看看是否可以为您创建一个特定的脚本。
Format Top 3 and Bottom 3 Values for each row
编辑:
我在我创建的一个小数据集上对此进行了一些测试。它似乎按要求工作。您只需要调整“cols”和“rows”以准确表示您的数据集。
EDIT2:代码已稍作修改以解决我发现的一个小问题。
Sub Conditions()
Dim i As Integer, j As Integer, cols As Integer, rows As Integer
cols = 2
rows = 10
i = 1
j = 1
Do While i <= cols
Do While j <= rows
With Range(Cells(j, i), Cells(j + 1, i)).FormatConditions.Add(xlTop10)
.SetFirstPriority
.TopBottom = xlTop10Top
.Rank = 1
.Percent = False
With .Interior
.PatternColorIndex = xlAutomatic
.Color = RGB(0, 255, 0)
.TintAndShade = 0
End With
End With
j = j + 2
Loop
i = i + 1
j = 1
Loop
i = 1
j = 1
Do While i <= cols
Do While j <= rows
With Range(Cells(j, i), Cells(j + 1, i)).FormatConditions.Add(xlTop10)
.SetFirstPriority
.TopBottom = xlTop10Bottom
.Rank = 1
.Percent = False
With .Interior
.PatternColorIndex = xlAutomatic
.Color = RGB(255, 0, 0)
.TintAndShade = 0
End With
End With
j = j + 2
Loop
i = i + 1
j = 1
Loop
End Sub