1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
Sub fusion_feuillet()
Const feuille_fusion = "FUSION"
Dim feuille_fusion_existe As Boolean
feuille_fusion_existe = False
For Each feuill In ActiveWorkbook.Worksheets
If UCase(feuill.name) = feuille_fusion Then feuille_fusion_existe = True: Exit For
Next
If feuille_fusion_existe = True Then
Worksheets(feuille_fusion).Cells.ClearContents
Else
ActiveWorkbook.Worksheets.Add
ActiveWorkbook.ActiveSheet.name = feuille_fusion
End If
col_resumé = 5 ' A adapter selon le fichier.
num_ligne_fusion = 2 ' on commence l'écriture à la ligne 2 , on peut mettre les entetes sur la ligne 1
For Each f1 In ActiveWorkbook.Worksheets
If UCase(f1.name) <> feuille_fusion Then
nb_lig_feuill = Worksheets(f1.name).Range("A65536").End(xlUp).Row
For ligne = 1 To nb_lig_feuill
If Worksheets(f1.name).Cells(ligne, col_resumé).Value = "OUI" Then
Worksheets(feuille_fusion).Range("A" & num_ligne_fusion & ":H" & num_ligne_fusion).Value = Worksheets(f1.name).Range("A" & ligne & ":H" & ligne).Value
num_ligne_fusion = num_ligne_fusion + 1
End If
Next
End If
Next f1
End Sub |
Partager