如何在VBA中声明一个全局变量? [英] How do I declare a global variable in VBA?
本文介绍了如何在VBA中声明一个全局变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我写了以下代码:
Function find_results_idle()
Public iRaw As Integer
Public iColumn As Integer
iRaw = 1
iColumn = 1
我收到错误信息:
Sub或Function中的无效属性
"invalid attribute in Sub or Function"
你知道我做错了吗?
我试图使用全局
而不是 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中声明一个全局变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文