本文介绍了工作表不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的问题是这段代码可行:
Dim x As String
x = Worksheets(Abgabe)。单元格(20,3).Value
但这不是:
Dim y As Worksheet
y = Worksheets(Abgabe)
另外,如果我使用ActiveWorkbook代码不起作用。
Dim y As Worksheet
y = ActiveWorkbook.Worksheets(Abgabe)
我收到此错误:
可能是什么问题?
解决方案
(你必须使用 Set
)
Dim y As Worksheet
设置y =工作表(Abgabe)
从MSDN a href =http://msdn.microsoft.com/en-us/library/aa192490.aspx> http://msdn.microsoft.com/en-us/library/aa192490.aspx ):
设置关键字:在VBA中,Set关键字是区分对象的
赋值和对象的默认属性。
I am trying to write an excel visual basic macro.
My Problem is that this code works:
Dim x As String
x = Worksheets("Abgabe").Cells(20, 3).Value
But this doesn't:
Dim y As Worksheet
y = Worksheets("Abgabe")
Also if I use ActiveWorkbook the code doesn't work.
Dim y As Worksheet
y = ActiveWorkbook.Worksheets("Abgabe")
I'm getting this error:
What could be the problem?
解决方案
Use this (You have to use Set
)
Dim y As Worksheet
Set y = Worksheets("Abgabe")
From MSDN (http://msdn.microsoft.com/en-us/library/aa192490.aspx):
Set Keyword: In VBA, the Set keyword is necessary to distinguish between
assignment of an object and assignment of the default property of the object.
这篇关于工作表不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!