Dépassement de capacité. trop de lignes

Bonjour tout le monde,

J'ai un soucis, je suis en train de reconstruire mes macro d'excel 2003 sur 2010 (ça va pas mal pour l'instant)

mais j'ai tout de meme un souci. sur cette macro:

Sub process15()

Dim Source As Variant

Source = Sheets("m").Range("A1").CurrentRegion

With Sheets("b")
For Each Cell In .Range("A2:A" & .Range("A" & .Cells.Rows.Count).End(xlUp).Row)
Cell.Offset(0, 20).ClearContents
For I = 1 To UBound(Source)

        If Cell.Offset(0, 15) = Source(I, 10) Then
        If Cell.Offset(0, 18) = Source(I, 9) Or Cell.Offset(0, 19) = Source(I, 9) Then

            Cell.Offset(0, 20) = Source(I, 8)
            Cell.Offset(0, 21) = Source(I, 9)
            'Else
            Exit For
             End If
            End If
      Next I
    Next Cell
   End With
  Erase Source
  Call process16
End Sub

j'ai un "dépassement de capacité" et

"For I = 1 To UBound(Source)"

de surligné.

j'ai essayé de changer le type sur la déclaration; ca bloque aussi mais il me met tableau attendu en surlignant simplement ubound.

(il faut dire que sur les feuilles, j'arrive a 100 000 lignes ou plus...ça change de 2003)

je sait que c'est parceque j'ai trop de lignes (en diminuant le nombre de ligne, ca fonctionne) mais je ne sait pas comment modifier pour lui déclarer autant de ligne.

Avez vous une idée de ce que je doit changer?

Merci

Bonjour

J'entrevoie 2 solutions

1ère

Limites ton tableau aux colonnes concernées

Adaptes l'indice de colonne dans ton nouveau tableau

Sub process15()
Dim Source As Variant

  Source = Sheets("m").Range("H1:J" & Sheets("m").Range("A" & Rows.Count).End(xlUp).Row)
  With Sheets("b")
    For Each Cell In .Range("A2:A" & .Range("A" & .Cells.Rows.Count).End(xlUp).Row)
      Cell.Offset(0, 20).ClearContents
      For i = 1 To UBound(Source)
        If Cell.Offset(0, 15) = Source(i, 3) Then
          If Cell.Offset(0, 18) = Source(i, 2) Or Cell.Offset(0, 19) = Source(i, 2) Then
            Cell.Offset(0, 20) = Source(i, 1)
            Cell.Offset(0, 21) = Source(i, 2)
             Exit For
          End If
        End If
      Next i
    Next Cell
  End With
  Erase Source
  Call process16
End Sub

2ème solution

N'utilises pas de tableau

Sub process15()
  With Sheets("b")
    For Each Cell In .Range("A2:A" & .Range("A" & .Cells.Rows.Count).End(xlUp).Row)
      Cell.Offset(0, 20).ClearContents
      For i = 1 To Sheets("m").Range("A" & Rows.Count).End(xlUp).Row
        If Cell.Offset(0, 15) = Sheets("m").Cells(i, 10) Then
          If Cell.Offset(0, 18) = Sheets("m").Cells(i, 9) Or Cell.Offset(0, 19) = Sheets("m").Cells(i, 9) Then
            Cell.Offset(0, 20) = Sheets("m").Cells(i, 8)
            Cell.Offset(0, 21) = Sheets("m").Cells(i, 9)
            Exit For
          End If
        End If
      Next i
    Next Cell
  End With
  Erase Source
  Call process16

Bonjour,

Bien!! ça a l'air de fonctionner (les deux). je verrais a l'utilisation mais apparemment c tout bon.

Un grand merci a toi!.

Rechercher des sujets similaires à "depassement capacite trop lignes"