Excel VBA如何从Module1模块访问在此工作簿模块中创建的数据



我想做的是:

在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

在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

这样的事情可能吗?

谢谢,

ThisWorkbook:

Option Explicit
Private Sub Workbook_Open()
ReDim cellArray(0)
cellArray(0) = "start"      
End Sub

Module1:

Option Explicit
Public cellArray() As String
Sub mySub()
Dim localvariable as string
localvariable = cellArray(0)
Debug.Print localvariable     
End Sub

相关内容

  • 没有找到相关文章

最新更新