我正在尝试根据范围(例如:range(I31:I10000")
)对范围进行排序,但出现错误。我正在使用Word vba访问Excel文件以提取一些数据,以将这些数据传输到我的Word文件中。
With xlBook.sheets(1)
' searching for the Reference
Set rg = .Cells.Find(what:="Référence")
refRow = .Range(rg.Address).Row
refColumn = .Range(rg.Address).Column
Set desigAdrs = .Cells.Find(what:="Désignation")
desigColumn = .Range(desigAdrs.Address).Column 'numero de colone Designation
tmp = "G" & (refRow + 2) & ":I" & 10000
.Sort.SortFields.Clear
.Sort.SortFields.Add2 Key:=.Range("I31:I10000") _
, SortOn:=xlSortOnValues, Order:=xlAscending
With .Sort
.SetRange .Range(tmp)
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End With
我希望它基于值进行排序,因为并非所有行都带有文本,但是出现错误