简体   繁体   中英

Select a column from maximum cell to first cell

I am new to Excel VBA. I got some data of 742 rows from this data I want to select from MAX value to first row. Eg Suppose my maximum value is "240" in cell "A480", so I want to select a column from cell "A480" to cell "A1".

Any one know how to do this.

Try this:

Sub MaxNumberRow()
    Dim max As Double
    Dim rowNum As Long

    With Sheet1
        max = WorksheetFunction.max(.Columns(1))

        If max > 0 Then
            rowNum = .Columns(1).Find(What:=max, After:=.Cells(1, 1), LookIn:=xlValues, LookAt:= xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False).Row
            Range(Cells(1, 1), Cells(rowNum, 1)).Select
        End If
    End With
End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM