2013 Excel宏错误&'方法'应用'对象'排序'失败'。 [英] 2013 Excel Macro Error "Method 'Apply' of object 'Sort' failed".

查看:177
本文介绍了2013 Excel宏错误&'方法'应用'对象'排序'失败'。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在2010版excel的excel文件中创建了一个宏。它一直很好,直到我得到2013版本。现在我收到一条错误,上面写着"运行时错误"-2147417848(80010108)'':对象'Sort'的方法'Apply'失败。 ".Apply"当我尝试调试时,
我宏的一部分(在底部)突出显示。有没有人有任何提示,如何解决这个问题? sort函数仍然在错误消息的后台运行。我在下面复制了我的宏。谢谢!


I created a macro in an excel file in the 2010 version of excel. It worked great until I got the 2013 version. Now I am getting an error that says "Run-time error '-2147417848 (80010108)'': Method 'Apply' of object 'Sort' failed. The ".Apply" part of my macro (at the bottom) is highlighted when I try to debug. Does anyone have any tips for how to fix this? The sort function still works in the background of the error message. I have copied my macro below. Thanks!

Sub Macro7()

'

'Macro7 Macro


'

On Error Resume Next

ActiveSheet.ShowAllData

On Error GoTo 0



    ActiveWorkbook.Names.Add Name:=" MyRange",RefersToR1C1:= _

        " = OFFSET('词汇表文件2'!R1C1 ,,, COUNTIF('词汇表文件2'!R1C4:R13C4,""?*""),4)" b
   范围("A21:E17000")。AdvancedFilter操作:= xlFilterInPlace,CriteriaRange:= _
$
       范围("MyRange"),唯一:= False

 

    ActiveWorkbook.Worksheets(" Glossary File 2")。Sort.SortFields.clear

    ActiveWorkbook.Worksheets(" Glossary File 2")。Sort.SortFields.Add Key:= Range(_

       " A6") ,SortOn:= xlSortOnValues,订单:= xlAscending,DataOption:= _
$
        xlSortNormal

   使用ActiveWorkbook.Worksheets("词汇表文件2")。排序

        .SetRange范围("A21:E17000")

        .Header = xlYes

        .MatchCase = False

        .Orientation = xlTopToBottom

        .SortMethod = xlPinYin

        。应用

   结束

Sub Macro7()
'
' Macro7 Macro

'
On Error Resume Next
ActiveSheet.ShowAllData
On Error GoTo 0

    ActiveWorkbook.Names.Add Name:="MyRange", RefersToR1C1:= _
        "=OFFSET('Glossary File 2'!R1C1,,,COUNTIF('Glossary File 2'!R1C4:R13C4,""?*""),4)"
    Range("A21:E17000").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
        Range("MyRange"), Unique:=False
 
    ActiveWorkbook.Worksheets("Glossary File 2").Sort.SortFields.clear
    ActiveWorkbook.Worksheets("Glossary File 2").Sort.SortFields.Add Key:=Range( _
        "A6"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
        xlSortNormal
    With ActiveWorkbook.Worksheets("Glossary File 2").Sort
        .SetRange Range("A21:E17000")
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With

推荐答案

您好,

>>它一直很好,直到我得到2013版本。现在我收到一条错误,上面写着"运行时错误"-2147417848(80010108)'':对象'Sort'的方法'Apply'失败。 <<

我尝试重现您在Excel 2013和Excel 2010中使用上述代码的问题,但它运行良好,我没有收到任何错误消息在"应用"行中。因此,我认为此问题可能与您的Excel工作簿中的数据有关,您是否介意通过SkyDrive分享
样本工作簿以帮助我们重现您的问题?

I try to reproduce you issue with the code above in both Excel 2013 and Excel 2010, but it works well and I don’t get any error message in the "Apply" line. So I assume this issue may be related to the data in your Excel workbook, would you mind sharing your sample workbook through SkyDrive to help us to reproduce your issue?

或者您可以尝试在安装了Excel 2013的其他计算机上运行此宏,以查看是否可以复制它。

Or you could try to run this macro in other machine which has Excel 2013 installed to see whether it can be reproduced.


这篇关于2013 Excel宏错误&'方法'应用'对象'排序'失败'。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆