Problème macro avec select case

Bonjour,

Pourriez-vous m'indiquer ce qui ne fonctionne pas dans ma macro??? Il me dit que j'ai un next sans for... ce qui est faux en réalité mais certainement pas dans la pratique

En vous remerciant d'avance

23scoutingauto.xlsm (22.34 Ko)

Bonjour Finplein,

Il doit te manquer le "end if" de "If UCase(Range("D" & J)) = attaquant Then" avant "next J".

Amicalement

Bonsoir,

Sans grande conviction. Il y a maintenant une erreur à la ligne 170

Option Explicit
Public Sub Calculer()
      Dim J As Long
      Dim Ligne As Long, Colonne As Integer
      Dim Line As Integer
      Dim Cel As Range
      Dim attaquant As Integer

10        For J = 2 To Range("A" & Rows.Count).End(xlUp).Row

20            For Each Cel In Range("I2:AB2,I13:AB13  ")
30                If Cel = Range("A" & J) Then Exit For
40            Next Cel

50            If Cel Is Nothing Then
60                MsgBox "Tableau " & Range("A" & J) & " non trouvé"
70            Else
80                Colonne = Cel.Column
90                If UCase(Range("B" & J)) = "*" Then Colonne = Colonne + 3
100           End If

110           Select Case UCase(Range("F" & J))
                  Case 0:   Colonne = Colonne + 1
120               Case "+": Colonne = Colonne + 2
130           End Select

140           Ligne = Cel.Row + 2 + Range("C" & J)
150           Cells(Ligne, Colonne) = Cells(Ligne, Colonne) + 1
              'End If

160           If UCase(Range("D" & J)) = attaquant Then Line = 25

170           While Cells(Line, 9).Value <> attaquant
180               Line = Line + 5
190           Wend

200           Select Case UCase(Range("E" & J))
                  Case 1: Cells(Line + 2, 12).Value = Cells(Line + 2, 12).Value + 1
210               Case 2: Cells(Line, 12).Value = Cells(Line, 12).Value + 1
220               Case 3: Cells(Line, 11).Value = Cells(Line, 11).Value + 1
230               Case 4: Cells(Line, 10).Value = Cells(Line, 10).Value + 1
240               Case 5: Cells(Line + 2, 10).Value = Cells(Line + 2, 10).Value + 1
250               Case 6: Cells(Line + 2, 11).Value = Cells(Line + 2, 11).Value + 1
260               Case 7: Cells(Line + 1, 12).Value = Cells(Line + 1, 12).Value + 1
270               Case 8: Cells(Line + 1, 11).Value = Cells(Line + 1, 11).Value + 1
280               Case 9: Cells(Line + 1, 10).Value = Cells(Line + 1, 10).Value + 1
290           End Select

300     Next J       

End Sub

Re,

Si notre ami veut bien nous dire si cela corrige l'erreur:

If UCase(Range("D" & J)) = attaquant Then

Line = 25

While Cells(Line, 9).Value <> attaquant

Line = Line + 5

Wend

Select Case UCase(Range("E" & J))

Case 1: Cells(Line + 2, 12).Value = Cells(Line + 2, 12).Value + 1

Case 2: Cells(Line, 12).Value = Cells(Line, 12).Value + 1

Case 3: Cells(Line, 11).Value = Cells(Line, 11).Value + 1

Case 4: Cells(Line, 10).Value = Cells(Line, 10).Value + 1

Case 5: Cells(Line + 2, 10).Value = Cells(Line + 2, 10).Value + 1

Case 6: Cells(Line + 2, 11).Value = Cells(Line + 2, 11).Value + 1

Case 7: Cells(Line + 1, 12).Value = Cells(Line + 1, 12).Value + 1

Case 8: Cells(Line + 1, 11).Value = Cells(Line + 1, 11).Value + 1

Case 9: Cells(Line + 1, 10).Value = Cells(Line + 1, 10).Value + 1

End Select

End If

Next J

Amicalement

Rechercher des sujets similaires à "probleme macro select case"