本文介绍了如何在 VBA 中声明全局变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我写了以下代码:
Function find_results_idle()
Public iRaw As Integer
Public iColumn As Integer
iRaw = 1
iColumn = 1
然后我收到错误消息:
Sub 或 Function 中的无效属性"
你知道我做错了什么吗?
Do you know what I did wrong?
我尝试使用 Global
而不是 Public
,但遇到了同样的问题.
I tried to use Global
instead of Public
, but got the same problem.
我试图将函数本身声明为`Public,但这也没有好处.
I tried to declare the function itself as `Public, but that also did no good.
我需要做什么来创建全局变量?
What do I need to do to create the global variable?
推荐答案
需要在函数外声明变量:
You need to declare the variables outside the function:
Public iRaw As Integer
Public iColumn As Integer
Function find_results_idle()
iRaw = 1
iColumn = 1
这篇关于如何在 VBA 中声明全局变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!