Sub Ex()
Dim i%, j%, x%, max%,rg As Range
For i = 1 To 10: x = IIf(i = 10, 4, 5)
For j = 1 To 10
If j = 1 Then
Set rg = Cells(7 * j, 5 * i - 3).Resize(1, x)
Else
Set rg = Union(rg, Cells(7 * j, 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): Exit For
End If
Next
Next i
End Sub
Sub Ex()
Dim i%, j%, x%, max%, rg As Range
For i = 1 To 10: x = IIf(i = 10, 4, 5)
For j = 1 To 10
If j = 1 Then
Set rg = Cells(7 * j, 5 * i - 3).Resize(1, x)
Else
Set rg = Union(rg, Cells(7 * j, 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
Next i
End Sub
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
If j = 10 Then a = -1
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
If i = 1 Then Stop
rg.Select
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
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
If j = 10 Then a = -1
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
Next i
End Sub作者: ziv976688 時間: 2019-6-11 16:00
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
Next i