我正在过滤一大组数据。作为该过程的一部分,我尝试在给定特定条件的情况下按升序或降序对单元格范围进行排序。
我研究了一些关于如何排序的选项。我正在努力理解这些参数。
If Abs(Worksheets("Points").Cells(i, 4).Value - Worksheets("Points").Cells(i - 1, 5).Value) > _
Abs(Worksheets("Points").Cells(j + 1, 4).Value - Worksheets("Points").Cells(i, 5).Value) Then
'Test to see whether logically the User moved from
'the previous Sensors to the time stamp Sensors (Decending) or
'from the time stamp Sensors to the next Sensor (Acending).
'This If is used to determine whether sorting must happen
'in an Acending or Decending order
'Time MUST be in date format!!!!!
Worksheets("Trips").Range(Cells(1, 23), Cells(k, 27)).Sort _
Key1:=Worksheets("Trips").Range(Cells(1, 27)), Order1:=xlDescending, Header:=xlNo
Else
Worksheets("Trips").Range(Cells(1, 23), Cells(k, 27)).Sort _
Key1:=Worksheets("Trips").Range(Cells(1, 27)), Order1:=xlAscending, Header:=xlNo
End If
发布于 2019-06-21 03:38:48
将Key1:=Worksheets("Trips").Range(Cells(1, 27))
更改为Key1:=Worksheets("Trips").Columns(27)
您告诉它按单个单元格排序,即第27列的第一行。
https://stackoverflow.com/questions/56690885
复制相似问题