vba - 应用程序定义或对象定义错误 1004

标签 vba excel runtime-error

我正在尝试定义两个范围(myADR 和 myOCC)以在 Linest 公式中使用。但是我不断收到此 1004 错误。我已经尝试了两种方法,第二种方法被注释掉了。有谁知道如何解决这个问题吗?

Sub LinestFormula()

Dim nCols As Integer
Dim myOCC As Range
Dim myADR As Range
Dim nRows3 As Integer

Range("A1").CurrentRegion.Select
nCols = Selection.Columns.Count

ActiveCell.Offset(5, 1).Resize(1, nCols - 2).Select
Selection.Copy
Range("A1").Select
Selection.End(xlToRight).Offset(0, 2).Select
ActiveCell = "OCC"
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial xlPasteValues, Transpose:=True
nRows3 = Selection.Rows.Count
'Selection = myOCC


Cells(5, 2).Select
Selection.Resize(1, nCols - 2).Select
Selection.Copy
Range("A1").Select
Selection.End(xlToRight).Offset(0, 3).Select
ActiveCell = "ADR"
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial xlPasteValues, Transpose:=True

Range("A1").End(xlToRight).Offset(1, 2).Resize(nRows3, 1).Select
Selection = myOCC
Range("A1").End(xlToRight).Offset(1, 3).Resize(nRows3, 1).Select
Selection = myADR

最佳答案

而不是:

Selection = myOCC

用途:

Set myOCC = Selection

等等

关于vba - 应用程序定义或对象定义错误 1004,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34158630/

相关文章:

excel - 使用 VBA 为 Excel 中的一系列单元格着色

c++ - 动态堆栈,编译时出错,开发编译器和 g++

vba - 如何使用 VBA 将 mm/dd/yyyy 更改为 dd/mm/yyyy

excel - 如何隐藏某一列中包含空白单元格的所有行?

vba - Workbooks.Open 返回与文件名不同的文件

c - 如何解决此 C 代码中的运行时错误?

ios - Swift 单元测试错误 - 找不到架构 i386 的 AWSCore 框架

python - 在尝试插入之前在数据库中查找现有条目

excel - 将 vba 转换为 Office-JS

excel - ORA-12560 : TNS: protocol adapter error issue: Excel 64-bit/Windows 10 64-bit