急!!!EXCEL 判断最大值,通过VBA,谢谢!!
发布网友
发布时间:2022-05-08 00:23
我来回答
共3个回答
热心网友
时间:2023-11-22 02:56
Sub MaxRec()
nRow = [c65536].End(xlUp).Row
With [e2].Resize(nRow - 1, 1)
.UnMerge
.ClearContents
End With
For i = 2 To nRow
nRec = Cells(i, 2).MergeArea.Count
Cells(i, 5).Resize(nRec, 1).MergeCells = True
Cells(i, 5) = Application.Max(Cells(i, 4).Resize(nRec, 1))
i = i + nRec - 1
Next
End Sub
热心网友
时间:2023-11-22 02:57
Sub cal_max()
irow = Application.Cells.SpecialCells(xlCellTypeLastCell).Row
i = 1
10 i = i + 1
If Cells(i, 2) = "" Then Exit Sub
If Cells(i, 1) <> "" Then
a = Cells(i, 3)
b = i
Else
If a < Cells(i, 3) Then a = Cells(i, 3)
If Cells(i + 1, 1) <> "" Or i = irow Then
Cells(b, 4) = a
Range(Cells(b, 4), Cells(i, 4)).Merge
Cells(b, 4).HorizontalAlignment = xlCenter
Cells(b, 4).VerticalAlignment = xlCenter
End If
End If
GoTo 10
End Sub
热心网友
时间:2023-11-22 02:57
直接用MAXIF函数可以追问多谢!
追答
见样表
数组+VBA实现你愿望也!!!
省略100字。。。。
热心网友
时间:2023-11-22 02:57
Sub MaxRec()
nRow = [c65536].End(xlUp).Row
With [e2].Resize(nRow - 1, 1)
.UnMerge
.ClearContents
End With
For i = 2 To nRow
nRec = Cells(i, 2).MergeArea.Count
Cells(i, 5).Resize(nRec, 1).MergeCells = True
Cells(i, 5) = Application.Max(Cells(i, 4).Resize(nRec, 1))
i = i + nRec - 1
Next
End Sub
热心网友
时间:2023-11-22 02:57
Sub cal_max()
irow = Application.Cells.SpecialCells(xlCellTypeLastCell).Row
i = 1
10 i = i + 1
If Cells(i, 2) = "" Then Exit Sub
If Cells(i, 1) <> "" Then
a = Cells(i, 3)
b = i
Else
If a < Cells(i, 3) Then a = Cells(i, 3)
If Cells(i + 1, 1) <> "" Or i = irow Then
Cells(b, 4) = a
Range(Cells(b, 4), Cells(i, 4)).Merge
Cells(b, 4).HorizontalAlignment = xlCenter
Cells(b, 4).VerticalAlignment = xlCenter
End If
End If
GoTo 10
End Sub
热心网友
时间:2023-11-22 02:57
直接用MAXIF函数可以追问多谢!
追答
见样表
数组+VBA实现你愿望也!!!
省略100字。。。。