I have a formula in which I need to change certain cells based on the iteration.
for i = 1 to NbData
Range(Cells(2, 10), Cells(Part1 + 1, 10)).FormulaR1C1 = _
"=(IF(AND('Arbre Positions'!R2C2=""HQV Asy"",'Arbre Positions'!R2C3=1),VLOOKUP(RC[-8],'Static Asymmetry - 1'!C[3]:C[6],4,FALSE),IF(AND('Arbre Positions'!R2C2=""HQV Asy"",'Arbre Positions'!R2C3=2),VLOOKUP(RC[-8],'Static Asymmetry - 2'!C[3]:C[6],4,FALSE),IF(AND('Arbre Positions'!R2C2=""HQV Opp"",'Arbre Positions'!R2C3=1),VLOOKUP(RC[-8],'Static Opportunity - 1 '!C[3]:C[" & _
"6],4,FALSE),IF(AND('Arbre Positions'!R2C2=""HQV Opp"",'Arbre Positions'!R2C3=2),VLOOKUP(RC[-8],'Static Opportunity - 2'!C[3]:C[6],4,FALSE),IF(AND('Arbre Positions'!R2C2=""HQV Sta"",'Arbre Positions'!R2C3=1),VLOOKUP(RC[-8],'Static Stability - 1'!C[3]:C[6],4,FALSE),IF(AND('Arbre Positions'!R2C2=""HQV Sta"",'Arbre Positions'!R2C3=2),VLOOKUP(RC[-8],'Static Stability - 2" & _
"'!C[3]:C[6],4,FALSE),""Pas trouvé dans les feuilles Statics"")))))))"
Next i
'Arbre Positions'!R2C2
and 'Arbre Positions'!R2C3
are the cells that should change for every iteration. So for the first it would be Row 2 and the next one row 3 ... as long as my loop continu.
So far I've tried to name the range 'Arbre Positions'!R2C2
and 'Arbre Positions'!R2C3
and then in the formula refere to the named range. Ex: Groupe = Sheet("Arbre Positions).Cells(1+i,2)
But when the formula is written into the cell, the reference does'nt work anymore..
I also tried something like Arbre Positions'!R&i+1&C2
.. But again it did'nt work...
Thank you for your help !
Aucun commentaire:
Enregistrer un commentaire