nagattaque
Messages postés230Date d'inscriptionjeudi 29 mai 2003StatutMembreDernière intervention 5 juin 2007
-
29 juin 2004 à 17:55
nagattaque
Messages postés230Date d'inscriptionjeudi 29 mai 2003StatutMembreDernière intervention 5 juin 2007
-
30 juin 2004 à 14:23
Bonjour tout le monde...
Bon voilà je manipule des array en VBA sous Excel... Tout marchait très bien du moment ou je traitais des tableaux avec une seule colonne. Mais voilà, partie sur ma lancée, je veux faire des manipulations avec un tableau avec x lignes et 3 colonnes.
J'ai donc en déclaration : public ID(1,2)
voici mon code qui merde :
Sub Get_all_Id()
'Write the Dpam_ID in array ID
For i = 1 To UBound(Dpam_ID)
'///////////////////////////////////////////////////////////
ReDim Preserve ID(i, 2) 'ca merde ici en faisant une erreur :
'"Array already dimensioned"
'//////////////////////////////////////////////////////////
ID(i, 0) = Dpam_ID(i)
Next i
'If one of the FC_ID is not in array ID, then it adds it
For j = 1 To UBound(FC_ID)
For i = 1 To UBound(ID)
If FC_ID(j) = ID(i, 0) Then
trouve = True
Exit For
Else
trouve = False
indice = j
End If
Next i
Select Case trouve
Case False
ReDim Preserve ID(UBound(ID) + 1, 2)
ID(UBound(ID) - 1, 0) = FC_ID(indice)
End Select
Next j
'write the id in the sheet all_ID
Sheets("all_ID").Visible = True
Sheets("all_ID").Select
For i = 1 To UBound(ID)
Cells(i, 1).Value = ID(i, 0)
Next i
Sheets("all_ID").Visible = False
End Sub
Tout marchait très bien avant que je ne rajoute des colonnes à mon tableau. La donne est simple, je veux un tableau avec un nombre de ligne qui varie (d'où le redim) et un nombre de colonne fixe = 3.