下午好,我有三列数据,如下所示:
我想找到每一行的最大值并将其放在对应行的E列中。例如,对于第一行:41.13,第二行:2143.404,依此类推。
谢谢您的回答。
我到目前为止的代码:
Dim LastRowIdent As Long, LastRowCant As Long
With Sheets("LOL")
LastRowIdent = .Cells(.Rows.Count, 1).End(xlUp).Row
.Range("A2:A" & LastRowIdent).Copy Destination:=Sheets("Animal").Range("A5")
LastRowCant = .Cells(.Rows.Count, 7).End(xlUp).Row
.Range("G2:G" & LastRowCant).Copy Destination:=Sheets("Animal").Range("B5")
End With
Application.DisplayAlerts = False
With Sheets("Animal")
Dim NumSheet As Long
NumSheet = ThisWorkbook.Worksheets.Count - 6
Range("F:F").Copy
Range("G:G").Resize(, NumSheet).Insert Shift:=xlToRight, Copyorigin:=xlFormatFromLeftOrAbove
Range("E:E").Copy
Range("F:F").Resize(, NumSheet).Insert Shift:=xlToRight, Copyorigin:=xlFormatFromLeftOrAbove
Range("C:C").Copy
Range("D:D").Resize(, NumSheet).Insert Shift:=xlToRight, Copyorigin:=xlFormatFromLeftOrAbove
Dim M As Long
For M = 1 To NumSheet + 1
Dim LastRowPrec As Long
LastRowPrec = ActiveWorkbook.Worksheets(2 + M).Cells(.Rows.Count, 11).End(xlUp).Row - 2
ActiveWorkbook.Worksheets(2 + M).Range("K2:K" & LastRowPrec).Copy Destination:=.Cells(5, 2 + M)
Next M
End With
最后,感谢@BigBen,该解决方案使用Rows(1).Address(False,False)如下:
Range(.Cells(5, 4 + NumSheet), .Cells(LastRowMax, 4 + NumSheet)).Formula = "=MAX(" & .Cells(5, 3).Address(False, False) & ":" & .Cells(5, 3 + NumSheet).Address(False, False) & ")"
谢谢@BigBen,我要找的那行是: Range(.Cells(5, 4 + NumSheet), .Cells(LastRowMax, 4 + NumSheet)).Formula = "=MAX(" & .Cells(5, 3).Address(False, False) & ":" & .Cells(5, 3 + NumSheet).Address(False, False) & ")"
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句