excel - 将 LONG 变量引用到工作表中的单元格
问题描述
如何将 Long 变量链接到 Excel 工作表中输入的值?我想创建大量行,虽然我可以直接在代码中更改变量(例如 x=100000),但是只要我将变量 x 链接到一个单元格(例如 x = Cells(1,1) 否值似乎被识别并打印到范围内。
解决方案
In order to simulate the cell being linked to the variable, you would have to add some code that gets triggered by something to write it to the cell.
Dim the variable as Public
or Global
(outside of the routine that sets it), so that other subroutines can "see" its value:
Public x as Long
and then add the code that sets its value to the worksheet in the Worksheet_SelectionChange
event or the Worksheet_Change
event (depending on how you want it to work):
Cells(1, 1) = x
If you are trying to set the variable automatically, then here's the opposite. Add this to the WorkSheet_Change
event:
If Target.Row = 1 and Target.Column = 1 Then
x = Cells(Target.Row, Target.Column)
End If
推荐阅读
- git - Git无法识别远程分支?
- angular - 如何更改 Angular Google Maps 组件中的 MapMarker z-index?
- firebase - Zapier & Firebase/Firestore -> Google 表格集成:在子集合更新/创建时在 google 表格中添加新行
- python - .buildozer 和 bin 文件夹未创建
- google-apps-script - 谷歌脚本:从一个标签复制一整列,并覆盖另一个标签中的列
- reactjs - Expo - 编译失败 - 无法解析“../Utilities/Platform”
- java - Swift 中等效的 Java 函数 Base64.encode(byte, 0)
- c# - 为什么我的程序在使用 EdgeJs 时会死机?
- python - pygame 控制器支持的问题
- javascript - 无效的挂钩调用。但我不知道为什么