Microsoft 365 interdire le double clic et clic droit sur une plage de cellules

Usine à gaz

XLDnaute Barbatruc
Supporter XLD
Bonsoir à toutes et à tous,

J'ai des UserForm qui s'ouvrent en SelectionChange.
VB:
Private Sub Worksheet_SelectionChange(ByVal r As Range)
If Not Intersect(r, Range("f19:f64")) Is Nothing Then
Application.EnableEvents = False
ActiveCell.Offset(0, 1).Resize(1, 27).Select
Application.EnableEvents = True
End If

If Not Intersect(r, Range("ab19:ab64")) Is Nothing Then
infos_com1.Show
[a1].Select
End If
If Not Intersect(r, Range("ac19:ac64")) Is Nothing Then
infos_com2.Show
[a1].Select
End If
If Not Intersect(r, Range("ad19:ad64")) Is Nothing Then
infos_com3.Show
[a1].Select
End If
If Not Intersect(r, Range("ae19:ae64")) Is Nothing Then
infos_com4.Show
[a1].Select
End If
End Sub

Pour ces cellules, j'ai besoin d'interdire le double clic et le clic droit.
N'ayant pas trouvé les bons codes ... je continue mes recherches...
Mais si vous aviez la solution, ça m'arrangerait bien :)
Si besoin, je mettrai un fichier test.
Avec mes remerciements,
lionel,
 

job75

XLDnaute Barbatruc
Bonsoir Lionel,
VB:
Private Sub Worksheet_BeforeDoubleClick(ByVal r As Range, Cancel As Boolean)
If Not Intersect(r, [f19:f64,ab19:ae64]) Is Nothing Then Cancel = True
End Sub

Private Sub Worksheet_BeforeRightClick(ByVal r As Range, Cancel As Boolean)
If Not Intersect(r, [f19:f64,ab19:ae64]) Is Nothing Then Cancel = True
End Sub
Bonne nuit.
 

_Thierry

XLDnaute Barbatruc
Repose en paix
Bonsoir @Usine à gaz , le Forum

Tu devrais essayer comme ceci à mon avis :
VB:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Range("A1:B10")) Is Nothing Then
    Cancel = True
End If
End Sub


Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Range("A1:B10")) Is Nothing Then
    Cancel = True
End If
End Sub

Bien à toi, à vous
@+Thierry

EDIT Salut Job, bonne nuit à toi aussi
 

Usine à gaz

XLDnaute Barbatruc
Supporter XLD
J'y reviens encore car malgré les codes cela n'empêche pas les ouvertures des UserForm quand je double clic ou clic droit dans les cellules de AB5 à AE20

Je n'arrive pas à comprendre comment l'empêcher.
Je joins le fichier que j'ai complété.
Auriez-vous la solution ?
Un grand merci :)
lionel,
 

Pièces jointes

  • dbleclic_droit_interdits_UF.xlsm
    36.8 KB · Affichages: 7

Usine à gaz

XLDnaute Barbatruc
Supporter XLD
Bonjour Gerard, _Thierry,

lol OUI j'étais fatigué hier :)
J'ai modifié le fichier en remettant vos codes. J'ai juste changé les n° de lignes.
Mais même situation, c'est le clic gauche activant "SelectionChange" qui s'exécute en 1er.
lionel,
 

Pièces jointes

  • dbleclic_droit_interdits_UF.xlsm
    36 KB · Affichages: 7

Discussions similaires

Membres actuellement en ligne

Aucun membre en ligne actuellement.

Statistiques des forums

Discussions
311 725
Messages
2 081 941
Membres
101 848
dernier inscrit
Djigbenou