Supprimé le contenu des cellules déverrouillés

Bonjour cher ami, j'ai mon classeur Excel qui comporte trois feuilles (paramètre 1 et paramètre 2, BASE DE DONNÉES ) dont je souhaite mettre à zéro les cellules à renseigner à partir d'un bouton que je vais affecté au macro . Ces cellules sont déverrouillés. Je compte testé le code suivant, quelqu'un peu m'aider.

Sub TestVerrouillage()

Dim Cel As Range

With Sheets("paramètre 1")

For Each Cel In Range("A1:Z1000") 'plage à adapter

If Cel.Locked = False Then Cel.ClearContents

With Sheets("paramètre 2")

For Each Cel In Range("A1:Z1000") 'plage à adapter

If Cel.Locked = False Then Cel.ClearContents

With Sheets("BASE DE DONNÉES ")

For Each Cel In Range("A1:Z1000") 'plage à adapter

If Cel.Locked = False Then Cel.ClearContents

Next Cel

End Sub

Bonjour Tinolacoro,

je te propose ce code VBA :

Option Explicit

Sub TestVerrouillage()
  Dim Cel As Range
  With Worksheets("paramètre 1")
    For Each Cel In .Range("A1:Z1000") 'plage à adapter
      If Cel.Locked = False Then Cel.ClearContents
    Next Cel
  End With
  With Worksheets("paramètre 2")
    For Each Cel In .Range("A1:Z1000") 'plage à adapter
      If Cel.Locked = False Then Cel.ClearContents
    Next Cel
  End With
  With Worksheets("BASE DE DONNÉES ")
    For Each Cel In .Range("A1:Z1000") 'plage à adapter
      If Cel.Locked = False Then Cel.ClearContents
    Next Cel
  End With
End Sub

je t'ai répondu aussi sur ton autre sujet (ta sub VideTableau) :

https://forum.excel-pratique.com/viewtopic.php?p=689540#p689540

dhany

Rechercher des sujets similaires à "supprime contenu deverrouilles"