Importation conditionnelle

Bonjour

Modifies ta macro

Option Explicit

Sub Recopie()
Dim J As Long, Ligne As Long, I As Integer
Dim F1 As Worksheet, F2 As Worksheet

  Application.ScreenUpdating = False
  Set F1 = Sheets("Feuil1")
  Set F2 = Sheets("Feuil2")

  Application.DisplayAlerts = False
  For I = Sheets.Count To 5 Step -1
    Sheets(I).Delete
  Next I
  Application.DisplayAlerts = True

  For J = 6 To F1.Range("B" & Rows.Count).End(xlUp).Row
    If FeuilleExiste(F1.Range("B" & J).Value) = False Then
      Sheets.Add(after:=Sheets(Sheets.Count)).Name = F1.Range("B" & J).Value
      For I = 1 To 12
        Cells(2, 20 + (I * 2)) = MonthName(I)
      Next I
    End If
    With Sheets(F1.Range("B" & J).Value)
      Ligne = .Range("B" & Rows.Count).End(xlUp).Row + 3
      F1.Rows(J).Copy .Range("A" & Ligne)
      For I = 1 To 12
        .Cells(Ligne + 1, 20 + (I * 2)) = F2.Cells(J, 69 + I)
      Next I
       .Range("A:A,C:I,K:U,AV:BO").EntireColumn.Hidden = True
    End With
  Next J
End Sub

Function FeuilleExiste(Nom As String) As Boolean
  On Error Resume Next
  FeuilleExiste = Sheets(Nom).Name <> ""
  On Error GoTo 0
End Function

Merci beaucoup ! j'avais également trouver une autre solution mais la tienne fonctionne egalement

Merci beaucoup pour votre aide

Rechercher des sujets similaires à "importation conditionnelle"