|
Sub 凌空一羽()
Application.ScreenUpdating = False
For i = 3 To 65536
'标题------------
If i Mod 4 = 3 Then
Range("bc" & i - 1 & ":be" & i - 1).Copy Cells(i - 1, "Aq")
Range("bh" & i - 1 & ":bj" & i - 1).Copy Cells(i - 1, "At")
End If
'------------标题
'内容------------
If (i - 3) Mod 4 < 2 Then '取前2个
gi = Int((i + 1) / 4) * 4 - 1
'执行只取唯一最小(大)值------------
If Application.CountIf(Cells(gi, "aw").Resize(1, 3), "<1") = 1 Then
gmin = Application.Min(Cells(gi, "aw").Resize(1, 3))
gmc = Application.Match(gmin, Cells(gi, "aw").Resize(1, 3), 0)
Else
gmax = Application.Max(Cells(gi, "aw").Resize(1, 3))
gmc = Application.Match(gmax, Cells(gi, "aw").Resize(1, 3), 0)
End If
'------------执行只取唯一最小(大)值
For j = 1 To 6
If j > 3 Then '分2个区域选择值
gb = Cells(i, "BG").Offset(0, gmc)
If Cells(i, j + 56) = gb Then
Cells(i, j + 42) = "等于参照": Cells(i, j + 42).Interior.ColorIndex = 5: Cells(i, j + 42).Font.ColorIndex = 2: Cells(i, j + 42).Font.Bold = True '颜色变化
ElseIf Cells(i, j + 56) > gb Then
Cells(i, j + 42) = "大于参照": Cells(i, j + 42).Interior.ColorIndex = 3: Cells(i, j + 42).Font.ColorIndex = 6: Cells(i, j + 42).Font.Bold = True
Else
Cells(i, j + 42) = "小于参照": Cells(i, j + 42).Interior.ColorIndex = 7: Cells(i, j + 42).Font.ColorIndex = 6: Cells(i, j + 42).Font.Bold = True
End If
If j - 3 = gmc Then Cells(i, j + 42) = "参照": Cells(i, j + 42).Interior.ColorIndex = 40: Cells(i, j + 42).Font.ColorIndex = 1: Cells(i, j + 42).Font.Bold = True
Else
ga = Cells(i, "BB").Offset(0, gmc)
If Cells(i, j + 54) = ga Then
Cells(i, j + 42) = "等于参照": Cells(i, j + 42).Interior.ColorIndex = 5: Cells(i, j + 42).Font.ColorIndex = 2: Cells(i, j + 42).Font.Bold = True
ElseIf Cells(i, j + 54) > ga Then
Cells(i, j + 42) = "大于参照": Cells(i, j + 42).Interior.ColorIndex = 3: Cells(i, j + 42).Font.ColorIndex = 6: Cells(i, j + 42).Font.Bold = True
Else
Cells(i, j + 42) = "小于参照": Cells(i, j + 42).Interior.ColorIndex = 7: Cells(i, j + 42).Font.ColorIndex = 6: Cells(i, j + 42).Font.Bold = True
End If
If j = gmc Then Cells(i, j + 42) = "参照": Cells(i, j + 42).Interior.ColorIndex = 40: Cells(i, j + 42).Font.ColorIndex = 1: Cells(i, j + 42).Font.Bold = True
End If
Next
End If
'------------ 内容
Next
Application.ScreenUpdating = True
End Sub
附件
按条件比较数值大小(修改).rar
(13.73 KB, 下载次数: 2)
|
|