Erreur de compilation next sans for

Bonjour

J'ai fait cette macro (a l'aide des forums) mais j'ai une erreur de compilation next sans for et je ne comprends pourquoi. Voici ce que j'ai fait :

Sub Exporter()

Dim ln, lgn, col, fs

Dim nf As String

Application.ScreenUpdating = False

Set fs = ActiveSheet

For ln = 2 To fs.Range("T" & Rows.Count).End(xlUp).Row

nf = fs.Range("T" & ln)

If (nf = "44w") And fs.Range("I" & ln) <> "X" Then

For i = 1 To Worksheets.Count

If Worksheets(i).Name = nf Then

lgn = Sheets(nf).Range("T" & Rows.Count).End(xlUp)(2).Row + 1

fs.Range("T" & ln & ":I" & ln).Copy Sheets(nf).Range("T" & lgn)

fs.Range("I" & ln) = "X"

End If

Next i

Next ln

MsgBox "Exportations terminées"

End Sub

Pouvez-vous m'aider SVP

Merci

Haut

Salut le Forum

Il te manquait un End if

Option Explicit

Sub Exporter()

    Dim ln, lgn, col, fs, i
    Dim nf As String

    Application.ScreenUpdating = False

    Set fs = ActiveSheet

    For ln = 2 To fs.Range("T" & Rows.Count).End(xlUp).Row

        nf = fs.Range("T" & ln)

        If (nf = "44w") And fs.Range("I" & ln) <> "X" Then
            For i = 1 To Worksheets.Count
                If Worksheets(i).Name = nf Then
                    lgn = Sheets(nf).Range("T" & Rows.Count).End(xlUp)(2).Row + 1
                    fs.Range("T" & ln & ":I" & ln).Copy Sheets(nf).Range("T" & lgn)
                    fs.Range("I" & ln) = "X"
                End If
            Next i
        End If
    Next ln

    MsgBox "Exportations terminées"
End Sub

Mytå

Super merci j'essaie cela

Merci Mytå

Le problème est réglé pour le next for mais ce que j'ai fait ne reporte rien et je ne sais pas pourquoi. Je vais continué à chercher

Merci

Rechercher des sujets similaires à "erreur compilation next"