In function of the work in my column 2 I want to select the row and copy it in a sheet with the same name. All the time I run the code, a message 1004 error appear.
`Sub ventilation()
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim LastRow As Integer
Dim dernierelilgne As Integer
Application.ScreenUpdating = False
' faire une boucle pour effacer les feuilles seelctionner'
For j = 1 To 9
    
    Sheets(j).Select
    LastRow = Range("A1000000").End(xlUp).Row
    For i = LastRow To 6 Step -1
        Sheets(j).Select
        Selection.Delete Shift:=xlUp
    Next i
    
    Sheets("source").Select
    derniereligne = Range("A1000000").End(xlUp).Row
      
      'en fonction du mot dans la colonne, envoyer vers la feuille correspondante'
    
    For k = 6 To derniereligne
    
        Sheets("source").Select
        If Sheets(j).Name = Cells(k, 2).Value Then
        
            Rows(k).Select
            Selection.Copy
            Sheets(j).Select
            LastRow = Range("A1000000").End(xlUp).Row + 1
            Cells(LastRow, 1).Select
            ActiveSheet.Paste
            
        End If
        
    Next k
    
Next j
Sheets("Source").Select
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
If you have a solution, please !
 
     
     
    
