【发布时间】:2019-02-11 00:03:54
【问题描述】:
我一直在尝试查找列的最小值和最大值,但似乎无法让我的代码正常工作。我尝试过 if 语句,for 循环,但似乎无法使其工作。我也一直在使用 application.worksheetfunction.min/max 并且无法正常工作。
Sub MinMax()
Dim xmax As Double
Dim xmin As Double
Dim TableRow As Integer
For i = 2 To lastrow
If cells("i,11").Value < cells(i + 1, 11).Value Then
xmin = cells(i, 11).Value
cells(3, 16).Value = xmin
End If
If cells(i, 11).Value > cells(i + 1, 11).Value Then
cells(2, 16).Value = xmax
End If
Next i
End Sub
【问题讨论】:
-
lastrow分配在哪里?这实际上是For i = 2 To 0。