Bonjour,
J'ai un petit problème avec un code VBA. Lorsque j'active mon tableau bilan "Classement général" il me demande de faire un débogage sur la ligne "Erase tablo"
Je vous mets le code ci dessous:
Option Explicit
Dim f, i, k, tablo, tabloG()
Private Sub Worksheet_Activate()
k = 0
For Each f In Worksheets
If f.Range("A2") = "NOM" And f.Range("B2") = "PRENOM" Then
tablo = f.Range("A3:X" & Application.Max(5, f.Range("B" & Rows.Count).End(xlUp).Row))
For i = 1 To UBound(tablo, 1)
ReDim Preserve tabloG(4, k + 1)
tabloG(0, k) = tablo(i, 1)
tabloG(1, k) = tablo(i, 2)
tabloG(2, k) = f.Name
tabloG(3, k) = tablo(i, 23)
k = k + 1
Next i
End If
Erase tablo
Next f
With Sheets("Classement général")
.Range("A2").CurrentRegion.Offset(2, 0).ClearContents
.Range("A3").Resize(UBound(tabloG, 2), 4) = Application.Transpose(tabloG)
.Range("A2:E" & UBound(tabloG, 2) + 2).Sort key1:=.Range("D3"), order1:=xlDescending, Header:=xlYes
For i = 1 To UBound(tabloG, 2)
If .Range("D" & i + 2) <> .Range("D" & i + 1) Then
.Range("E" & i + 2) = i
Else
.Range("E" & i + 2) = .Range("E" & i + 1)
End If
Next i
End With
End Sub
Je n'ai pas mis le fichier excel car il contient les noms de mes élèves et je dois encore l'anonymiser. Si besoin je pourrai le joindre.
Merci d'avance pour vos réponses