我正在尝试在单独的工作表中对范围进行排序.但是,我一直收到这条消息:
'1004': "The sort reference is not valid. Make sure it's within the data you want to sort, and the first Sort By box isn't the same or blank.
Run Code Online (Sandbox Code Playgroud)
我检查了范围,它们都存在并且正在工作.
代码如下:
Dim EmpBRange As String
EmpBRange = Sheets("EmployeeData").Cells(Cells.Rows.Count, "B").End(xlUp).Row
Worksheets("EmployeeData").Range("K3:K" & EmpBRange).Sort Key1:=Range("K3:K" & EmpBRange), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Run Code Online (Sandbox Code Playgroud)
提前致谢