I'm writing some Excel VBA code and one section displays a message by selecting an entire sheet which then pops up with the desired text, Sheet2 if you like. However, the following code then refuses to run with complaint:
我正在编写一些Excel VBA代码,一个部分通过选择整个工作表来显示一条消息,然后弹出所需的文本Sheet2(如果您愿意的话)。但是,以下代码拒绝投诉:
Method 'Range' of object '_Worksheet' failed.
In the code being called I still refer to the sheet I try to modify with Sheet1, for example Sheet1.Range(Cells(1, 1), Cells(101, 101)).Value = ""
, but to no avail.
在被调用的代码中,我仍然引用我尝试使用Sheet1修改的工作表,例如Sheet1.Range(Cells(1,1),Cells(101,101))。Value =“”,但无济于事。
What am I doing wrong please?
我做错了什么?
1 个解决方案
#1
5
That is because the Cells
Object is not fully qualified.
这是因为Cells对象不是完全限定的。
Change your code to
将您的代码更改为
Sheet1.Range(Sheet1.Cells(1, 1), Sheet1.Cells(101, 101)).Value = ""
#1
5
That is because the Cells
Object is not fully qualified.
这是因为Cells对象不是完全限定的。
Change your code to
将您的代码更改为
Sheet1.Range(Sheet1.Cells(1, 1), Sheet1.Cells(101, 101)).Value = ""