Macro protection cellules

Bonjour,

Ci-joint un fichier excel

1/ La macro permet de protéger le les cellules des colonnes 5 et 6 du tableau bleu

Comment protéger celles du tableau orange aussi svp?

Merci

Bonjour,

Dans le module de la feuille, remplaces le code existant par celui-ci :

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    Dim rng As Range

    Set rng = Me.ListObjects(1).ListColumns(5).DataBodyRange
    If Not Intersect(Target, rng) Is Nothing Then Target.Offset(, -1).Select

    Set rng = Me.ListObjects(1).ListColumns(6).DataBodyRange
    If Not Intersect(Target, rng) Is Nothing Then Target.Offset(, -1).Select

    Set rng = Me.ListObjects(2).ListColumns(5).DataBodyRange
    If Not Intersect(Target, rng) Is Nothing Then Target.Offset(, -1).Select

    Set rng = Me.ListObjects(2).ListColumns(6).DataBodyRange
    If Not Intersect(Target, rng) Is Nothing Then Target.Offset(, -1).Select

End Sub

Bonjour,

Une autre proposition.

Cdlt.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim lo As ListObject, lCol As Integer, lRow As Long
    If Target.CountLarge > 1 Then Exit Sub
    If Target.ListObject Is Nothing Then Exit Sub
    Set lo = Target.ListObject
    With lo
        lCol = Target.Column - .HeaderRowRange.Cells(1).Column + 1
        lRow = Target.Row - .HeaderRowRange.Row + 1
        If lCol > 4 Then .Range.Cells(lRow, 4).Select
    End With
End Sub

Super,

Merci Theze et Jean,

Je note que Theze propose une macro pour y indiquer chaque tableau et Jean pour tous les tableaux de la feuille!

Merci encore

Bonjour,

Merci de ton retour.

J'ai supprimé la précaution inutile !...

Bonnes fêtes de fin d'année.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim lo As ListObject, lCol As Integer, lRow As Long
    If Target.ListObject Is Nothing Then Exit Sub
    Set lo = Target.ListObject
    With lo
        lCol = Target.Column - .HeaderRowRange.Cells(1).Column + 1
        lRow = Target.Row - .HeaderRowRange.Row + 1
        If lCol > 4 Then .Range.Cells(lRow, 4).Select
    End With
End Sub

Bonjour,

Je note que Theze propose une macro pour y indiquer chaque tableau...

Forcément, puisque telle est la question !

1/ La macro permet de protéger le les cellules des colonnes 5 et 6 du tableau bleu

Comment protéger celles du tableau orange aussi svp?

Exact These,

Merci encore

Ok Jean,

C'est noté,

Merci

Rechercher des sujets similaires à "macro protection"