VBA Excel sort range by specific column

后端 未结 3 449
名媛妹妹
名媛妹妹 2020-11-30 02:26

I have a table that can contain any number of rows:

\"enter

As I said it can c

3条回答
  •  旧时难觅i
    2020-11-30 03:00

    Try this code:

    Dim lastrow As Long
    lastrow = Cells(Rows.Count, 2).End(xlUp).Row
    Range("A3:D" & lastrow).Sort key1:=Range("B3:B" & lastrow), _
       order1:=xlAscending, Header:=xlNo
    

提交回复
热议问题