我有一个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>有人能从这个错误中看出问题所在吗?(如果需要的话,我可以张贴我正在使用的代码)
发布于 2015-07-28 15:47:04
确保排序字段引用了正确的范围,如下面从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有时,当添加新的排序字段时,您会复制和粘贴代码,然后忘记更新密钥属性的范围。
https://stackoverflow.com/questions/31664869
复制相似问题