vba - 在 vba 中循环时更改原始集合

标签 vba excel

我有一个这样的集合:

Dim BrokerCol as New Collection
'Added some data to the Collection
BrokerCol .Add temp_broker, BROKER_NAME

我正在像这样遍历集合:
For Each collectionitem In BrokerCol 
 If ((collectionitem.Bid - bid_average) / bid_average) < pThresholdValue Then
     'Want to change something here in BrokerCol instead of Collection Item
 Else
Next collectionitem

如前所述,上面我想更改 BrokerCol 中的某些内容,而不是更改 Collection Item。我怎么做?

我试过这个:
BrokerCol.Item(CollectionItem).Bid = 1

它给了我一个“类型不匹配”错误。不知道如何解决这个问题。

最佳答案

您是否尝试过仅使用

collectionitem.bid = 1 

它与集合中的对象相同。

关于vba - 在 vba 中循环时更改原始集合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32621847/

相关文章:

excel - VBA POST 格式问题

VBA,如果字符串包含某个字母

excel - VBA Excel 代码无需打开文件即可检索数据

c# - 如何从 DataTable 向 Excel 添加其他工作表

excel - 用excel处理变量

excel - 我想比较 SSIS 中两个不同 Excel 文件的行数并获取电子邮件警报

VBA将单词的第一个字母更改为大写

excel - 保存文件时忽略斜线

vba - 如果自动过滤器已经打开,如何使用 if 语句将其关闭,否则关闭

regex - vba正则表达式最后一次出现