第一種:
將第一欄及第二欄的值相乘後,將乘積的最大值顯示在D2中
Sub try()
Dim i, j As Integer
Dim m As Integer
Dim a, b As Integer
a = Cells(2, 2).Value * Cells(2, 1).Value
For i = 2 To 35
b = Cells(i + 1, 2).Value * Cells(i + 1, 1).Value
If a > b Then
m = a
Else
m = b
a = b
End If
Next i
Cells(2, 4).Value = m
End Sub