Excel(条件格式)
Excel (conditional formatting)
美好的一天,
我有一个数据集,如下所示(示例)。我需要突出显示 A1 和 A2 之间的最高数字,然后是 A3 和 A4 之间的最高数字,A5 和 A6 之间的最高数字,依此类推。 B列和C列等相同。
我想要以绿色突出显示的最高值,以红色突出显示的最低值?有任何想法吗。这是一个大数据集,手动将花费太长时间。
以下链接问题的答案是回答您问题的开始。您将需要使用 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
美好的一天,
我有一个数据集,如下所示(示例)。我需要突出显示 A1 和 A2 之间的最高数字,然后是 A3 和 A4 之间的最高数字,A5 和 A6 之间的最高数字,依此类推。 B列和C列等相同。 我想要以绿色突出显示的最高值,以红色突出显示的最低值?有任何想法吗。这是一个大数据集,手动将花费太长时间。
以下链接问题的答案是回答您问题的开始。您将需要使用 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