Suppression feuille

Résolu
Herta -  
 Herta -
Bonjour, à tous,
J'aimerai savoir pourquoi le code macro suivant ne fonctionne pas.Il s'agit de supprimer toutes les feuilles sauf les deux feuilles dénomés "Brouillon" et "Bulletin"

Merci d'avance pour votre aide

Application.DisplayAlerts = False
Dim Sht As Worksheet
For Each Sht In ActiveWorkbook.Sheets
If Sht.Name <> "brouillon" Or Sht.Name <> "Bulletin" Then
MsgBox Sht.Name
Sht.Select
ActiveSheet.Delete
End If
Next Sht

Rows("7:1000").Select
Selection.Delete Shift:=xlUp
Range("A7").Select
Application.DisplayAlerts = True

End Sub

1 réponse

  1. Utilisateur anonyme
     
    Bonjour Herta,

    Essaye avec ce code VBA :

    
    Sub Essai()
    
      Dim Sht As Worksheet
    
      Application.DisplayAlerts = False
    
      For Each Sht In Worksheets
        With Sht
          If .Name <> "Brouillon" And .Name <> "Bulletin" Then .Delete
        End With
      Next Sht
    
      Rows("7:1000").Delete Shift:=xlUp: [A7].Select
      Application.DisplayAlerts = True
    
    End Sub
    
    

    Dis-moi ce que tu en penses, et si ça marche.
    Sinon, indiques-moi ce qui ne vas pas.

    Cordialement.  😊
     
    0
    1. Herta
       
      Bjr Albkan;

      J'ai testé le macro que tu m'a proposé et ça marche parfaitement.
      Je te remercie pour ton aide

      A plus
      0