Blocage Copier sur certaines colonnes

ludozebest

XLDnaute Nouveau
Bonjour, je souhaiterai bloquer la fonction copier/coller et drag&drop sur certaines colonnes de ma feuille de calcul.

Pour cela dans la feuille de calcul en question, j'ai insérer le code suivant :

Code:
Function AlphaCol() 'détermination dela lettre de la colonne

AlphaCol = Split(ActiveCell.Address, "$")(1)

End Function




Private Sub Worksheet_SelectionChange(ByVal Target As Range) 'Suppression du copier/coller

'Détermination Lettre colonne
Z = AlphaCol
'Détermination si colonne applicable
y = Application.WorksheetFunction.Or(Z = "E", Z = "O", Z = "Y", Z = "AI", Z = "AS")

If y = "Vrai" Then
Application.CutCopyMode = False
Application.CellDragAndDrop = False
Else
Application.CutCopyMode = True
Application.CellDragAndDrop = True
End If

End Sub

Le soucis est que lorsque je suis pas sur une des colonnes en question (e,o,y,ai,as), je ne peux pas faire un copier coller...:confused:


Est-ce qqun saurait où je me suis planté...

Merci pour vos réponses.

LL
 
G

Guest

Guest
Re : Blocage Copier sur certaines colonnes

Bonjour,

Avec ceci peut-être:

Code:
[COLOR=BLUE]Private[/COLOR] [COLOR=BLUE]Sub[/COLOR] Worksheet_SelectionChange([COLOR=BLUE]ByVal[/COLOR] Target [COLOR=BLUE]As[/COLOR] Range)
    [COLOR=BLUE]Select[/COLOR] [COLOR=BLUE]Case[/COLOR] Split(ActiveCell.Address, [i]"$"[/i])(1)
    [COLOR=BLUE]Case[/COLOR] [i]"E"[/i], [i]"O"[/i], [i]"Y"[/i], [i]"Z"[/i], [i]"AI"[/i], [i]"[COLOR=BLUE]AS[/COLOR]"[/i]
        Application.CutCopyMode = [COLOR=BLUE]False[/COLOR]
        Application.CellDragAndDrop = [COLOR=BLUE]False[/COLOR]
    [COLOR=BLUE]Case[/COLOR] [COLOR=BLUE]Else[/COLOR]
        Application.CutCopyMode = [COLOR=BLUE]True[/COLOR]
        Application.CellDragAndDrop = [COLOR=BLUE]True[/COLOR]
    [COLOR=BLUE]End[/COLOR] [COLOR=BLUE]Select[/COLOR]
[COLOR=BLUE]End[/COLOR] [COLOR=BLUE]Sub[/COLOR]

A+
 

Discussions similaires

Réponses
7
Affichages
436

Statistiques des forums

Discussions
312 668
Messages
2 090 739
Membres
104 643
dernier inscrit
adriano22