我有一个vba类,我用它来管理同一个ListObject的不同视图(即过滤和排序),并且得到一些似乎与排序有关的损坏。使用以下记录的错误修复Excel似乎很容易:
...Excel completed file level validation and repair. Some parts of this workbook may have been
repaired or discarded.</info></additionalInfo><removedRecords summary="Following is a list of
removed records:"><removedRecord>Removed Records: Sorting from /xl/tables/table1.xml
part (Table)</removedRecord></removedRecords></recoveryLog>
任何人都可以看到此错误可能导致的问题吗? (如果需要,我可以发布我正在使用的代码)
答案 0 :(得分:0)
Make sure that your sort fields are referencing the correct ranges, as in the code below copied from colinlegg.wordpress.com/2015/07/08/naughty-sorts.
With wksTarget.Sort
With .SortFields
.Clear
.Add _
Key:=wksTarget.Range("A2:A6"), _
SortOn:=xlSortOnValues, _
Order:=xlDescending, _
DataOption:=xlSortNormal
.Add _
Key:=wksTarget.Range("B2:B6"), _
SortOn:=xlSortOnValues, _
Order:=xlDescending, _
DataOption:=xlSortNormal
.Add _
Key:=wksTarget.Range("C2:C6"), _
SortOn:=xlSortOnValues, _
Order:=xlDescending, _
DataOption:=xlSortNormal
End With
.SetRange wksTarget.Range("A1:C6")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Sometimes you copy and paste code when adding new sort fields and then forget to update the range for the Key property.