EASY:VBA:期待通过列表框,选择的内容 [英] EASY: vba: Looking through a listbox and selecting the contents

查看:312
本文介绍了EASY:VBA:期待通过列表框,选择的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这是很简单的东西,它的滑落我的我的现在。我怎么循环,虽然一个列表框,选择的内容?

这里的code我做了现在:

 昏暗allGrps作为整数
昏暗我作为整数
allGrps = lstAllGroups.ListCount
对于i = 1到allGrps
lstAllGroups
下一个
 

解决方案

请记住,列表框的索引从零开始,所以你一定要减一关,从我:

 对于i = 1到allGrps
    lstAllGroups.Selected(I  -  1)=真
接下来我
 

另外,还要确保你有 SelectSheetsList.MultiSelect = fmMultiSelectMulti ,以便能够在列表中选择多个项目。

请参阅 ListBox中的文档了解更多信息。

I know this is something really simple and it's slipping my mine right now. how do I loop though a listbox and select the contents?

Here's the code I've made right now:

Dim allGrps As Integer
Dim i As Integer
allGrps = lstAllGroups.ListCount
For i = 1 To allGrps
lstAllGroups
Next

解决方案

Keep in mind that the listbox is zero-indexed so you've got to subtract one off from i:

For i = 1 To allGrps
    lstAllGroups.Selected(i - 1) = True
Next i

Also, make sure you've got SelectSheetsList.MultiSelect = fmMultiSelectMulti in order to be able to select multiple items in the list.

See the ListBox documentation for more info.

这篇关于EASY:VBA:期待通过列表框,选择的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆