我正在尝试使用另一个工作表中的动态长度列表填充列表框。我希望最终能够从此列表框中选择多个项目来触发一些vlookup和进一步的计算。
但是,我不确定如何使用我的列表填充列表框。当我运行/单步执行以下代码时,我没有收到任何错误消息,但它没有填充框
Sub FilterUniqueData()
Dim Lrow As Long, test As New Collection
Dim Value As Variant, temp() As Variant
ReDim temp(0)
Dim Value1 As Variant
On Error Resume Next
With Workbooks("Copy of SWR1304 (Future Development Risk Assessment) Strathaven.xls").Sheets("Non Household Metered Users")
Lrow = .Range("h" & Rows.Count).End(xlUp).Row
temp = .Range("h12:h" & Lrow).Value
End With
For Each Value In temp
If Len(Value) > 0 Then test.Add Value, CStr(Value)
Next Value
ReDim temp(0)
Workbooks("DMA_metered_tool").Worksheets("DMA list").Shapes("List Box 2").ControlFormat.RemoveAllItems
For Each Value In test
Worksheets("DMA list").Shapes("List Box 2").ControlFormat.AddItem Value
Next Value
Set test = Nothing
End Sub
任何建议都非常感谢。
干杯