![]() |
|
Forum
|
|
|
#1 (permalink) |
|
XLDnaute Nouveau
Date d'inscription: septembre 2007
Messages: 16
|
Cette rubrique sera alimentée j'espère régulièrement. Voici pour débuter.
__________________________________________________ ___________ Pour tous les codes à venir il faut 1 - Ouvrir VBE (Alt + F11) 2 - Se placer sur le projet VBA du classeur C'est du style : VBAProject(Classeur1) Si la fenêtre des projets n'est pas visible, il suffit de cliquer sur le menu Affichage > Explorateur de projets. 3 - Dans les exemples donnés, il y aura juste un affichage d'une msgbox __________________________________________________ ___________ 1 - Evènements du classeur Le code doit se trouver dans le "ThisWorkbook" 1.1 - A l'ouverture du classeur Code:
Private Sub Workbook_Open() MsgBox "Merci d’avoir ouvert ce fichier" End Sub Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean) MsgBox "A BIENTOT, merci d’avoir consulté le fichier" End Sub 2 - Evènements d'une feuille Le code doit se trouver dans le code de la feuille concernée 2.1 - Quand on clique sur la cellule "A1" uniquement Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Application.Intersect(Target, Range("A1")) Is Nothing Then
MsgBox "Click on " & Target.Address
End If
End Sub
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Application.Intersect(Target, Range("A:A")) Is Nothing Then
MsgBox "Click on " & Target.Address
End If
End Sub
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Application.Intersect(Target, Range("A:E")) Is Nothing Then
MsgBox "Click on " & Target.Address
End If
End Sub
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Application.Intersect(Target, Range("A1:A10")) Is Nothing Then
MsgBox "Click on " & Target.Address
End If
End Sub
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Application.Intersect(Target, Range("A1:A12, D4:D10, D20, D22, D55, E1:E12")) Is Nothing Then
MsgBox "Click on " & Target.Address
End If
End Sub
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Application.Intersect(Target, Range("A:A, C:C, E:E")) Is Nothing Then
MsgBox "Click on " & Target.Address
End If
End Sub
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Not Application.Intersect(Target, Rows(1)) Is Nothing Then MsgBox "Click on " & Target.Address End If End Sub Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Not Application.Intersect(Target, Range(Rows(1), Rows(3))) Is Nothing Then MsgBox "Click on " & Target.Address End If End Sub Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Not Application.Intersect(Target, Range(Rows(1), Rows(3))) Is Nothing Then If Application.Intersect(Target, Rows(2)) Is Nothing Then MsgBox "Click on " & Target.Address End If End If End Sub Merci à Brigitte, Skoobi et Thierry pour leurs participations Dernière modification par David XLD 24/01/2008 à 16h34. |
|
|
|
| ANNONCES | |
![]() |
| Outils de la discussion | |
|
|
Discussions similaires
|
||||
| Discussion | Auteur | Forum | Réponses | Dernier message |
| jumelage de 2 macros evènementielles | Jouxte | Forum Excel | 0 | 28/11/2006 22h23 |
| Compil de macros événementielles | criscris11 | Forum Excel | 3 | 01/11/2006 00h21 |
| créer 2 macros evenementielles de meme type sur le workbook?? | Tonino7 | Forum Excel | 14 | 09/07/2006 09h52 |
| 2 macros évènementielles??? | Jacques | Forum Excel Downloads - Archives | 2 | 04/02/2005 23h56 |
| Macros Evenementielles | Vincent | Forum Excel Downloads - Archives | 0 | 13/10/2004 18h27 |