For R = 1 To 10
a = IIf(R = 10, -1, 0)
Set rg = Cells(7 * R + a, 2).Resize(1, 49)
rg.Font.ColorIndex = 1: rg.Font.Size = 12: rg.Font.Bold = False '恢復字體格式
max = WorksheetFunction.max(rg)
For Each cel In rg
If cel = max Then cel.Font.ColorIndex = 3: cel.Font.Bold = True
Next
Next
經套取n7822123大大原有的程式碼~問題已解決。 謝謝!
Sub Ex()
Dim i%, j%, x%, a%, max%, rg As Range
For i = 1 To 10: x = IIf(i = 10, 4, 5)
For j = 1 To 10
a = IIf(j = 10, -1, 0)
If j = 1 Then
Set rg = Cells(7 * j, 5 * i - 3).Resize(1, x)
Else
Set rg = Union(rg, Cells(7 * j + a, 5 * i - 3).Resize(1, x))
End If
Next j
rg.Interior.Color = -1 '恢復無色
max = WorksheetFunction.max(rg)
For Each cel In rg
If cel = max Then cel.Interior.Color = RGB(255, 255, 0)
Next
Set rg = Cells(71, 5 * i - 3).Resize(1, x)
rg.Interior.Color = -1 '恢復無色
max = WorksheetFunction.max(rg)
For Each cel In rg
If cel = max Then cel.Interior.ColorIndex = 38
Next
Next i
End Sub