I am trying to sort a table where I am sorting based on the data entries in Column E. However, when I am using my code, (below) my rows for which the column become disorganized and mismatched. Each row needs to contain the same data entries as before they were sorted, only moving to be sorted based on the values in column E. I am trying to sort this table, with my expected outcome shown below:
Code:
With Worksheets("Fruits")
Dim FruitsLastRow As Long
Dim FruitsKeyRange As Range
FruitsLastRow = .Range("E" & .Rows.Count).End(xlUp).Row
Set DashboardRange = Range("E17:G" & FruitsLastRow)
DashboardRange.Sort key1:=Range("E17:E" & FruitsLastRow), _
order1:=xlAscending, Header:=xlNo _
End With
You need to specify just the top cell instead of all cells for key1 parameter ( Range.Sort example ).
DashboardRange.Sort key1:=Range("E17"), order1:=xlAscending, Header:=xlNo
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.