使用NewEnum()而不是Collection类的Range对象(即For Each)

我正在构build一个自定义集合类Record。

我目前通过以下方式启用了我的类的枚举:

private pRecord as Collection ' ' Enables enumeration of the pRecords Collection (ie using For Each). ' Public Property Get NewEnum() As IUnknown Attribute NewEnum.VB_UserMemId = -4 Attribute NewEnum.VB_MemberFlags = "40" Set NewEnum = pRecord.[_NewEnum] End Property 

目前,pRecord是一个集合,它包含一些Range对象的行中的单个单元格,例如Range(“A1:C6”),Row(1)。

是否可以将实际的行Range设置为枚举对象而不是pRecords集合? 如果是这样,你怎么做?

我认为这一定是可能的,因为你已经可以在范围对象上使用For Each了。

你有没有尝试用你的集合代替一个Range对象?