复制时运行时错误'1004' [英] Run-time error '1004' while copying

查看:137
本文介绍了复制时运行时错误'1004'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行这个代码时,我得到了臭名昭着的运行时错误,我不明白为什么:

I'm getting the infamous Run-time error when I run this code, and I don't understand why:

With ThisWorkbook .Sheets(Data)
.Range(Cells(row1,column1),Cells(row2,column1))。Copy
End With

row1,column1和row2都定义为整数。

row1, column1 and row2 are all defined as Integers.

第二行代码弹出错误。

我可以得到一些见解吗?

Can I get some insight please?

推荐答案

你忘了。之前单元格(正如您在中的范围之内)

You forgot the "." before Cells (as you are within the With scope of the Sheet Data)

With ThisWorkbook.Sheets("Sheet2")
    .Range(.Cells(1, 1), .Cells(2, 2)).Copy
End With

测试了上面的例子,现在它适用于我。

Tested the above example and now it works for me.

这篇关于复制时运行时错误'1004'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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