excel - 如何使用用户窗体从列表框中插入列单元格?
问题描述
我有 PHP 和 .Net 的背景,但我是 VBA 新手。是否可以在来自用户表单的列表框的 excel 中添加特定的列单元格?谢谢。
解决方案
我已经设法插入一个来自用户表单的新列。这是我的代码。
Private Sub btnSaveParameters_Click()
Dim totalParameters As Integer
totalParameters = ListBox1.ListCount
Dim lColumn As Long
Dim addlColumn As Long
Dim ws As Worksheet
Set ws = Worksheets("Reference")
Dim i As Integer
i = 0
Do Until i >= Me.ListBox1.ListCount
MsgBox "The vaue of i is: " & ListBox1.List(i)
lColumn = ws.Cells(3, ws.Columns.Count).End(xlToLeft).Column
addlColumn = lColumn + 1
ws.Cells(3, addlColumn).Value = Me.ListBox1.List(i)
i = i + 1
Loop
End Sub
推荐阅读
- autowired - Symfony4 注入环境变量和自动装配错误“无法自动装配服务”
- ruby-on-rails - 使用 Angular $http.post 时会话保留过时的值?
- node.js - 为什么我在 WSL 中的 npm start 上出现 Ganache 错误?
- tensorflow - 有没有办法在 keras 中输出具有多个值的指标?
- sql - 如何在 SQL Server 触发器中使用回滚事务修复 If 条件
- c++ - 在 C++ 中初始化字符串向量的向量
- c++ - c++程序的资产文件夹路径[windows]
- kotlin - 错误:尝试导入包时未解析的引用
- javascript - 如何让 Webpack 识别动态导出
- java - 如何从不在内部类中的 ActionListener 返回值