excel - 无法设置列表属性,类型不匹配 - 列表框
问题描述
我正在尝试从工作表中添加一些数据。
该工作表具有来自 SQL 服务器的结果作为记录集我正在尝试将数据提取到用户表单中的列表框有一个列数,因为大多数值即将到来。但很少有单元格在 excel 中具有价值,但在列表框中没有反映
对于那些情况,我正在以下皮棉上
“无法设置列表属性。类型不匹配”
.List(.ListCount - 1, i - 1) = rw.Cells(1, i).Value
Dim lbtarget As MSForms.ListBox
Dim rngSource As Range
Dim rw As Range
Dim i
Dim lRow
Dim strng As String
Dim lCol As Long, lRow1 As Long
UserForm1.ListBox1.Visible = True
lRow = Sheets("macro").Range("b" & Rows.Count).End(xlUp).Row
Set rngSource = Sheets("macro").Range("B15:E" & lRow)
Set lbtarget = UserForm1.ListBox1
With lbtarget
.ColumnCount = 4
.ColumnWidths = "48;120;220"
For Each rw In rngSource.Rows
UserForm1.ListBox1.Visible = True
If rw.Cells(1, 1) <> "" Then
.AddItem ""
For i = 1 To .ColumnCount
Dim texdf
texdf = rw.Cells(1, i)
Debug.Print texdf
.List(.ListCount - 1, i - 1) = rw.Cells(1, i).Value
Next
End If
Next
End With
UserForm1.ListBox1.Visible = True
Else
MsgBox " NO Data Provided, please enter the SEQ_Number", vbOKCancel
End If
解决方案
推荐阅读
- date - 如何验证 ocl 中的 java.util.Date 属性?
- ruby-on-rails - 对活动模型序列化器属性的嵌套查询
- java - 从Android中的JSONObject中提取元素
- reactjs - 单击注销按钮时出现内存泄漏错误
- neo4j - 如何添加到属性的字符串值而不是在 Cypher Neo4J 中重写它?
- typescript - 使用实体存储库的全局实例在事务中保存多个对象(TypeORM)是否安全?
- r - 基于子类对 2 个匹配的队列进行重塑,然后进行连续的 McNemar 测试
- javascript - web api和接口有什么区别?
- postgresql - flyway 后的 Flyway 迁移错误:基线
- python - 缺少 CSRF 令牌 - Flask WTForms Python