我正在尝试动态选择列表框中的值。但我不能这样做。我收到一个错误,对象不支持此属性或方法。
这是代码,
ReqSearchvalue = Range("B" & reqrow).Value
Sheets("Main").Activate
With Sheets("Main").Ent_ListBox
.Values = ReqSearchvalue
.SetFocus = ReqSearchvalue
End With
请分享您的想法。提前致谢 !
感谢@Peh 纠正了这一点。
循环List
查找您正在查找的值的索引,然后将 设置.Selected(idx)
为 True。
Dim i As Long, found As Boolean
With Worksheets("Main").OLEObjects("Ent_ListBox").Object
For i = 0 To .ListCount - 1
If .List(i) = ReqSearchvalue Then
found = True
Exit For
End If
Next i
If found then .Selected(i) = True
End With
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句