Help needed with a collection. Lot of thanks

M

mtorres.f

Hi everyone, Im really new at this and Im working with a collection.
I want to simplify it:

This is part of the code
Set nuevoactivo = New Activo


nuevoactivo.Codigo = Sheets("Cartera SII").Cells(k, 1)
nuevoactivo.sFPG000015 = Cells(i,j)
nuevoactivo.sFPG000632 = Cells(i,j)
nuevoactivo.sFIG002826 = Cells(i,j)
nuevoactivo.sFIG002827 = Cells(i,j)
nuevoactivo.sFIG002852 = Cells(i,j)
nuevoactivo.sFIB002233 = Cells(i,j)
nuevoactivo.sFIH002231 = Cells(i,j)
nuevoactivo.sFPG001144 = Cells(i,j)
....
.....
.....
.....
mlistaactivos.Add nuevoactivo, nuevoactivo.Codigo


an I also have an array with the codes:


Fondos(1)=FPG000015
Fondos(2)=FPG000632
Fondos(3)=FIG002826
Fondos(4)=FIG002827
Fondos(5)=FIG002852
Fondos(6)=FIB002233
......
......


I tryed to do the following but it doesn´t work:


For i=1 to n
For j= 1 to n


nuevoactivo.s & Fondos(i)= cells(i,j)


next j
next i


Any idea? I really appreciate it!!
 
T

Tony Jollans

Hi,

Firstly this is a Word newsgroup and you appear to be working in Excel.
However your problem does not seem to be application related.

I'm still not completely understanding what you're doing so let's see if I
can summarise the core of what I think your problem is ...

* You create a new object (type Activo)
* You set some properties of it
* You add it to a collection

* You have an array of partial property names

* You want to walk the collection and the properties in a single loop
* Or ... you just want to walk the properties of a single object?

This is not possible in the general case, but with object properties it can
be done using CallByName, something like this ...

For each nuevoactivo in mlistaactivos
For i = 1 to n
CallByName nuevoactivo, "s" & Fondos(i), vbSet, Cells(i,j)
Next i
Next

--
Enjoy,
Tony

Hi everyone, Im really new at this and Im working with a collection.
I want to simplify it:

This is part of the code
Set nuevoactivo = New Activo


nuevoactivo.Codigo = Sheets("Cartera SII").Cells(k, 1)
nuevoactivo.sFPG000015 = Cells(i,j)
nuevoactivo.sFPG000632 = Cells(i,j)
nuevoactivo.sFIG002826 = Cells(i,j)
nuevoactivo.sFIG002827 = Cells(i,j)
nuevoactivo.sFIG002852 = Cells(i,j)
nuevoactivo.sFIB002233 = Cells(i,j)
nuevoactivo.sFIH002231 = Cells(i,j)
nuevoactivo.sFPG001144 = Cells(i,j)
....
.....
.....
.....
mlistaactivos.Add nuevoactivo, nuevoactivo.Codigo


an I also have an array with the codes:


Fondos(1)=FPG000015
Fondos(2)=FPG000632
Fondos(3)=FIG002826
Fondos(4)=FIG002827
Fondos(5)=FIG002852
Fondos(6)=FIB002233
......
......


I tryed to do the following but it doesn´t work:


For i=1 to n
For j= 1 to n


nuevoactivo.s & Fondos(i)= cells(i,j)


next j
next i


Any idea? I really appreciate it!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top