Bonjour
Je veux executer une macro à partir d'un click droit sur une cellule , cette
macro s'execute deux foix lorsqu'il y a un argument.Comment eviter celà
Merci de votre aide (ci joint le code)
'au niveau de la feuille
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Application.ScreenUpdating = False 'au hasard
Application.EnableEvents = False 'au hasard
If Target.Address = "$A$1" Then 'selection cellule A1
Dim X, N As Integer
X = Application.CommandBars("Cell").Controls.Count
For N = 1 To X
Application.CommandBars("Cell").Controls(1).Delete
Next N
With Application.CommandBars("Cell").Controls.Add
.Caption = "TEST" 'Intitulé du menu
.OnAction = ThisWorkbook.Name & "!test(3)" 'Message est le nom de la
macro à lancer
End With
Else
Application.CommandBars("Cell").Reset
End If
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
et dans un module
Sub test(lenombre As Integer)
MsgBox lenombre
End Sub
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
papou
Bonjour Et pourquoi pas un simple : Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address = "$A$1" Then test (3) End Sub
Cordialement Pascal
"david" a écrit dans le message de news:4045ca4c$0$5916$
Bonjour Je veux executer une macro à partir d'un click droit sur une cellule , cette
macro s'execute deux foix lorsqu'il y a un argument.Comment eviter celà Merci de votre aide (ci joint le code) 'au niveau de la feuille
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) Application.ScreenUpdating = False 'au hasard Application.EnableEvents = False 'au hasard If Target.Address = "$A$1" Then 'selection cellule A1 Dim X, N As Integer X = Application.CommandBars("Cell").Controls.Count For N = 1 To X Application.CommandBars("Cell").Controls(1).Delete Next N With Application.CommandBars("Cell").Controls.Add .Caption = "TEST" 'Intitulé du menu .OnAction = ThisWorkbook.Name & "!test(3)" 'Message est le nom de la macro à lancer End With Else Application.CommandBars("Cell").Reset End If Application.EnableEvents = True Application.ScreenUpdating = True End Sub
et dans un module
Sub test(lenombre As Integer) MsgBox lenombre End Sub
Bonjour
Et pourquoi pas un simple :
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$A$1" Then test (3)
End Sub
Cordialement
Pascal
"david" <desoletropdespam@club-internet.fr> a écrit dans le message de
news:4045ca4c$0$5916$7a628cd7@news.club-internet.fr...
Bonjour
Je veux executer une macro à partir d'un click droit sur une cellule ,
cette
macro s'execute deux foix lorsqu'il y a un argument.Comment eviter celà
Merci de votre aide (ci joint le code)
'au niveau de la feuille
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Application.ScreenUpdating = False 'au hasard
Application.EnableEvents = False 'au hasard
If Target.Address = "$A$1" Then 'selection cellule A1
Dim X, N As Integer
X = Application.CommandBars("Cell").Controls.Count
For N = 1 To X
Application.CommandBars("Cell").Controls(1).Delete
Next N
With Application.CommandBars("Cell").Controls.Add
.Caption = "TEST" 'Intitulé du menu
.OnAction = ThisWorkbook.Name & "!test(3)" 'Message est le nom de la
macro à lancer
End With
Else
Application.CommandBars("Cell").Reset
End If
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
et dans un module
Sub test(lenombre As Integer)
MsgBox lenombre
End Sub
Bonjour Et pourquoi pas un simple : Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address = "$A$1" Then test (3) End Sub
Cordialement Pascal
"david" a écrit dans le message de news:4045ca4c$0$5916$
Bonjour Je veux executer une macro à partir d'un click droit sur une cellule , cette
macro s'execute deux foix lorsqu'il y a un argument.Comment eviter celà Merci de votre aide (ci joint le code) 'au niveau de la feuille
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) Application.ScreenUpdating = False 'au hasard Application.EnableEvents = False 'au hasard If Target.Address = "$A$1" Then 'selection cellule A1 Dim X, N As Integer X = Application.CommandBars("Cell").Controls.Count For N = 1 To X Application.CommandBars("Cell").Controls(1).Delete Next N With Application.CommandBars("Cell").Controls.Add .Caption = "TEST" 'Intitulé du menu .OnAction = ThisWorkbook.Name & "!test(3)" 'Message est le nom de la macro à lancer End With Else Application.CommandBars("Cell").Reset End If Application.EnableEvents = True Application.ScreenUpdating = True End Sub
et dans un module
Sub test(lenombre As Integer) MsgBox lenombre End Sub
david
Il faut avoir le choix d'executer la macro avec le click droit Merci "papou" <DesolePasDeMail> a écrit dans le message de news:%
Bonjour Et pourquoi pas un simple : Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address = "$A$1" Then test (3) End Sub
Cordialement Pascal
"david" a écrit dans le message de news:4045ca4c$0$5916$
Bonjour Je veux executer une macro à partir d'un click droit sur une cellule , cette
macro s'execute deux foix lorsqu'il y a un argument.Comment eviter celà Merci de votre aide (ci joint le code) 'au niveau de la feuille
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) Application.ScreenUpdating = False 'au hasard Application.EnableEvents = False 'au hasard If Target.Address = "$A$1" Then 'selection cellule A1 Dim X, N As Integer X = Application.CommandBars("Cell").Controls.Count For N = 1 To X Application.CommandBars("Cell").Controls(1).Delete Next N With Application.CommandBars("Cell").Controls.Add .Caption = "TEST" 'Intitulé du menu .OnAction = ThisWorkbook.Name & "!test(3)" 'Message est le nom de la
macro à lancer End With Else Application.CommandBars("Cell").Reset End If Application.EnableEvents = True Application.ScreenUpdating = True End Sub
et dans un module
Sub test(lenombre As Integer) MsgBox lenombre End Sub
Il faut avoir le choix d'executer la macro avec le click droit
Merci
"papou" <DesolePasDeMail> a écrit dans le message de
news:%238woJKSAEHA.3184@TK2MSFTNGP09.phx.gbl...
Bonjour
Et pourquoi pas un simple :
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$A$1" Then test (3)
End Sub
Cordialement
Pascal
"david" <desoletropdespam@club-internet.fr> a écrit dans le message de
news:4045ca4c$0$5916$7a628cd7@news.club-internet.fr...
Bonjour
Je veux executer une macro à partir d'un click droit sur une cellule ,
cette
macro s'execute deux foix lorsqu'il y a un argument.Comment eviter celà
Merci de votre aide (ci joint le code)
'au niveau de la feuille
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Application.ScreenUpdating = False 'au hasard
Application.EnableEvents = False 'au hasard
If Target.Address = "$A$1" Then 'selection cellule A1
Dim X, N As Integer
X = Application.CommandBars("Cell").Controls.Count
For N = 1 To X
Application.CommandBars("Cell").Controls(1).Delete
Next N
With Application.CommandBars("Cell").Controls.Add
.Caption = "TEST" 'Intitulé du menu
.OnAction = ThisWorkbook.Name & "!test(3)" 'Message est le nom de
la
macro à lancer
End With
Else
Application.CommandBars("Cell").Reset
End If
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
et dans un module
Sub test(lenombre As Integer)
MsgBox lenombre
End Sub
Il faut avoir le choix d'executer la macro avec le click droit Merci "papou" <DesolePasDeMail> a écrit dans le message de news:%
Bonjour Et pourquoi pas un simple : Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address = "$A$1" Then test (3) End Sub
Cordialement Pascal
"david" a écrit dans le message de news:4045ca4c$0$5916$
Bonjour Je veux executer une macro à partir d'un click droit sur une cellule , cette
macro s'execute deux foix lorsqu'il y a un argument.Comment eviter celà Merci de votre aide (ci joint le code) 'au niveau de la feuille
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) Application.ScreenUpdating = False 'au hasard Application.EnableEvents = False 'au hasard If Target.Address = "$A$1" Then 'selection cellule A1 Dim X, N As Integer X = Application.CommandBars("Cell").Controls.Count For N = 1 To X Application.CommandBars("Cell").Controls(1).Delete Next N With Application.CommandBars("Cell").Controls.Add .Caption = "TEST" 'Intitulé du menu .OnAction = ThisWorkbook.Name & "!test(3)" 'Message est le nom de la
macro à lancer End With Else Application.CommandBars("Cell").Reset End If Application.EnableEvents = True Application.ScreenUpdating = True End Sub
et dans un module
Sub test(lenombre As Integer) MsgBox lenombre End Sub