0
好吧,所以我有一个通常按稀有排序的项目列表,但对于一个特定的操作,我需要对它进行排序,以便匹配函数可以对其进行排序,所以我设置了它直到为匹配函数进行排序,然后将其恢复。然而,匹配函数正在提取排序之前的行。有谁知道这可能会如何解决?代码如下(我包括庞大的排序代码):Excel VBA匹配函数忽略更新排序
'Sort for Match Function
Sheets("Item List").Select
Range("L2").Select
Range(Selection, Selection.End(xlToRight)).Select
Range("L2:U2").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlDown)).Select
ActiveWorkbook.Worksheets("Item List").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Item List").Sort.SortFields.Add Key:=Range(_
"L2:L300"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Item List").Sort
.SetRange Range("L1:U300")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Dim x As Integer
x = Application.Match(BuyItem.Value, Range("TraderItems"))
MsgBox (x)
'Sort back to Rarity
Sheets("Item List").Select
Range("L2").Select
Range(Selection, Selection.End(xlToRight)).Select
Range("L2:U2").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlDown)).Select
ActiveWorkbook.Worksheets("Item List").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Item List").Sort.SortFields.Add Key:=Range(_
"R2:R300"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Item List").Sort
.SetRange Range("L1:U300")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
替换'实际范围TraderItems'。 –
什么是Range(“TraderItems”))?你有一个名为范围“TraderItems”?你在哪里设置它? –
此外,如果您已经计算过,请尝试在排序后在其中放置强制计算范围... – TheSilkCode