excel - Excel VBA 如何从 Module1 模块访问在 Thisworkbook 模块中创建的数据
问题描述
我想做的是:
在 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
这样的事情甚至可能吗?
谢谢,
解决方案
本工作簿:
Option Explicit
Private Sub Workbook_Open()
ReDim cellArray(0)
cellArray(0) = "start"
End Sub
模块1:
Option Explicit
Public cellArray() As String
Sub mySub()
Dim localvariable as string
localvariable = cellArray(0)
Debug.Print localvariable
End Sub
推荐阅读
- spring-boot - 使用 SpringDoc webflux 支持时无法显示 Swagger/OpenApi 文档
- sql-server - 允许在 Oracle 中为 SSRS 报告提供多个值
- jestjs - 无法使用 jest 在 vuejs 中获取 vuex 存储 getters 数据
- ios - 如何从不同的函数调用 TextField
- gitlab-ci - 来自 kubectl 命令中另一个项目的 Gitlab CI 参考文件
- javascript - 在 Chrome 扩展中使用 Google API 电子表格 JS 删除值
- python - 隐藏(或不显示)mplfinance 中的图
- sql - 如何在 SQL SERVER 2016+ 中生成 SHA-3(256) 哈希
- node.js - 如何在 Github 操作中设置 sendgrid 邮件?
- r - “无法分配大小向量......”即使 memory.limit() 和 memory.size() 更高,也会出现错误