gpt4 book ai didi

excel - .Add2 生成运行时错误 '438' : Object doesn't support this property or method in Excel VBA

转载 作者:行者123 更新时间:2023-12-04 20:52:57 26 4
gpt4 key购买 nike

我收到以下错误:

Run-time error '438': Object doesn't support this property or method



使用以下代码
ActiveWorkbook.Worksheets("Backend 3").Sort.SortFields.Add2 Key:=Range("A2") _
, SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal"

此错误出现在一台笔记本电脑中,而在另一个系统中,我没有遇到任何问题。在这两个系统中,它都是 2016 版本。

这是我的代码的其余部分:
Range("A2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Backend 3").Select
Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ActiveWorkbook.Worksheets("Backend 3").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Backend 3").Sort.SortFields.Add2 Key:=Range("A2") _
, SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Backend 3").Sort
.SetRange Range("A2:A1001")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("A10").Select
ActiveWorkbook.Save
Sheets("Backend 3").Select
ActiveWindow.SelectedSheets.Visible = False
Sheets("Backend 2").Select
ActiveWindow.SelectedSheets.Visible = False
Range("E11").Select
ActiveWorkbook.Save
Range("A1").Select

最佳答案

您是否检查过有问题的机器上没有任何缺失的引用资料。
如果它可以在一台机器上运行,但不能在另一台机器上运行,那么一台机器或电子表格的副本一定有一些“错误”。

您是否使用显式选项?

你编译过代码吗?

将工作表从可以工作的机器复制到不能工作的机器上。

Excel 2016 的版本是否相同?

也许办公室安装需要维修。

就我个人而言,我会摆脱所有那些“事件”和“选择”并定义合适的对象来使用。

关于excel - .Add2 生成运行时错误 '438' : Object doesn't support this property or method in Excel VBA,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53833429/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com