[英]Excel VBA How to access data created in Thisworkbook module from Module1 module
What I am trying to do is this:我想做的是:
In the ThisWorkbook module:在 ThisWorkbook 模块中:
Option Explicit
'//== Does something need to go up here? ==//
_________________
Private Sub Workbook_Open()
Public cellArray() As String
'//== init cellArray() ==//
cellArray(0) = "start" '//== for example ==//
End Sub
In the Module1 module:在 Module1 模块中:
Option Explicit
'//== Does something need to go up here? ==//
_________________
Sub mySub()
Dim localvariable as string
local variable = ThisWorkbook.cellArray(0) '//== for example ==//
'//== Does something different need to go here? ==//
End Sub
Is something like this even possible?这样的事情甚至可能吗?
Thanks,谢谢,
ThisWorkbook:本工作簿:
Option Explicit
Private Sub Workbook_Open()
ReDim cellArray(0)
cellArray(0) = "start"
End Sub
Module1:模块1:
Option Explicit
Public cellArray() As String
Sub mySub()
Dim localvariable as string
localvariable = cellArray(0)
Debug.Print localvariable
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.