j'ai la macro suivante ( qui vient du forum ) et que j'ai adapté pour mettre
en forme des commentaires dans une plage définie.
Problème, j'ai une erreur d'exécution 1004 dans l'instruction :
If Not intersect(Target, Range("Plg")) Is Nothing Then ActiveSheet.Unprotect
Else: Exit Sub
Private Sub Worksheet_Activate()
Dim Plg As Range
Set Plg = [C6:H35,L6:M35]
If Not intersect(Target, Range("Plg")) Is Nothing Then ActiveSheet.Unprotect
Else: Exit Sub
ActiveSheet.Unprotect
For Each c In Plg
If Not c.Comment Is Nothing Then
With c.Comment.Shape.OLEFormat.Object
.AutoSize = True
.Font.Name = "Tahoma"
.Font.Size = 10
.Font.Bold = False
.ShapeRange.Fill.ForeColor.SchemeColor = 42
End With
End If
Next c
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
Jacky
Bonjour,
Il n'y a pas d'argument "Target" dans l'événement "Activate()" Bien que je ne comprends pas comment se fait la sélection dans la plage. En remarque avec l'évenement "Change" La syntaxe serait: '------------------------ Private Sub Worksheet_Activate() '*****Private Sub Worksheet_Change(ByVal Target As Range) Dim Plg As Range Set Plg = [C6:H35,L6:M35] If Not Intersect(ActiveCell, Plg) Is Nothing Then '*****If Not Intersect(target, Plg) Is Nothing Then ActiveSheet.Unprotect For Each c In Plg If Not c.Comment Is Nothing Then With c.Comment.Shape.OLEFormat.Object .AutoSize = True .Font.Name = "Tahoma" .Font.Size = 10 .Font.Bold = False .ShapeRange.Fill.ForeColor.SchemeColor = 42 End With End If Next c End If End Sub '----------------------
-- Salutations JJ
"Infogroup" a écrit dans le message de news:
Bonjour à toutes et à tous,
j'ai la macro suivante ( qui vient du forum ) et que j'ai adapté pour mettre en forme des commentaires dans une plage définie. Problème, j'ai une erreur d'exécution 1004 dans l'instruction : If Not intersect(Target, Range("Plg")) Is Nothing Then ActiveSheet.Unprotect Else: Exit Sub
Private Sub Worksheet_Activate() Dim Plg As Range Set Plg = [C6:H35,L6:M35] If Not intersect(Target, Range("Plg")) Is Nothing Then ActiveSheet.Unprotect Else: Exit Sub ActiveSheet.Unprotect For Each c In Plg If Not c.Comment Is Nothing Then With c.Comment.Shape.OLEFormat.Object .AutoSize = True .Font.Name = "Tahoma" .Font.Size = 10 .Font.Bold = False .ShapeRange.Fill.ForeColor.SchemeColor = 42 End With End If Next c
End Sub
Merci par avance pour votre aide
Cordialement
Infogroup
Bonjour,
Il n'y a pas d'argument "Target" dans l'événement "Activate()"
Bien que je ne comprends pas comment se fait la sélection dans la plage.
En remarque avec l'évenement "Change"
La syntaxe serait:
'------------------------
Private Sub Worksheet_Activate()
'*****Private Sub Worksheet_Change(ByVal Target As Range)
Dim Plg As Range
Set Plg = [C6:H35,L6:M35]
If Not Intersect(ActiveCell, Plg) Is Nothing Then
'*****If Not Intersect(target, Plg) Is Nothing Then
ActiveSheet.Unprotect
For Each c In Plg
If Not c.Comment Is Nothing Then
With c.Comment.Shape.OLEFormat.Object
.AutoSize = True
.Font.Name = "Tahoma"
.Font.Size = 10
.Font.Bold = False
.ShapeRange.Fill.ForeColor.SchemeColor = 42
End With
End If
Next c
End If
End Sub
'----------------------
--
Salutations
JJ
"Infogroup" <Infogroup70@orange.fr> a écrit dans le message de news:
ejwsHAquJHA.3848@TK2MSFTNGP02.phx.gbl...
Bonjour à toutes et à tous,
j'ai la macro suivante ( qui vient du forum ) et que j'ai adapté pour
mettre en forme des commentaires dans une plage définie.
Problème, j'ai une erreur d'exécution 1004 dans l'instruction :
If Not intersect(Target, Range("Plg")) Is Nothing Then
ActiveSheet.Unprotect Else: Exit Sub
Private Sub Worksheet_Activate()
Dim Plg As Range
Set Plg = [C6:H35,L6:M35]
If Not intersect(Target, Range("Plg")) Is Nothing Then
ActiveSheet.Unprotect Else: Exit Sub
ActiveSheet.Unprotect
For Each c In Plg
If Not c.Comment Is Nothing Then
With c.Comment.Shape.OLEFormat.Object
.AutoSize = True
.Font.Name = "Tahoma"
.Font.Size = 10
.Font.Bold = False
.ShapeRange.Fill.ForeColor.SchemeColor = 42
End With
End If
Next c
Il n'y a pas d'argument "Target" dans l'événement "Activate()" Bien que je ne comprends pas comment se fait la sélection dans la plage. En remarque avec l'évenement "Change" La syntaxe serait: '------------------------ Private Sub Worksheet_Activate() '*****Private Sub Worksheet_Change(ByVal Target As Range) Dim Plg As Range Set Plg = [C6:H35,L6:M35] If Not Intersect(ActiveCell, Plg) Is Nothing Then '*****If Not Intersect(target, Plg) Is Nothing Then ActiveSheet.Unprotect For Each c In Plg If Not c.Comment Is Nothing Then With c.Comment.Shape.OLEFormat.Object .AutoSize = True .Font.Name = "Tahoma" .Font.Size = 10 .Font.Bold = False .ShapeRange.Fill.ForeColor.SchemeColor = 42 End With End If Next c End If End Sub '----------------------
-- Salutations JJ
"Infogroup" a écrit dans le message de news:
Bonjour à toutes et à tous,
j'ai la macro suivante ( qui vient du forum ) et que j'ai adapté pour mettre en forme des commentaires dans une plage définie. Problème, j'ai une erreur d'exécution 1004 dans l'instruction : If Not intersect(Target, Range("Plg")) Is Nothing Then ActiveSheet.Unprotect Else: Exit Sub
Private Sub Worksheet_Activate() Dim Plg As Range Set Plg = [C6:H35,L6:M35] If Not intersect(Target, Range("Plg")) Is Nothing Then ActiveSheet.Unprotect Else: Exit Sub ActiveSheet.Unprotect For Each c In Plg If Not c.Comment Is Nothing Then With c.Comment.Shape.OLEFormat.Object .AutoSize = True .Font.Name = "Tahoma" .Font.Size = 10 .Font.Bold = False .ShapeRange.Fill.ForeColor.SchemeColor = 42 End With End If Next c
End Sub
Merci par avance pour votre aide
Cordialement
Infogroup
Daniel.C
Bonjour. 1. Target n'est défini nulle part. 2. Plg est un objet Range (tout comme Target), tu dois l'employer tel quel. Cordialement. Daniel
Bonjour à toutes et à tous,
j'ai la macro suivante ( qui vient du forum ) et que j'ai adapté pour mettre en forme des commentaires dans une plage définie. Problème, j'ai une erreur d'exécution 1004 dans l'instruction : If Not intersect(Target, Range("Plg")) Is Nothing Then ActiveSheet.Unprotect Else: Exit Sub
Private Sub Worksheet_Activate() Dim Plg As Range Set Plg = [C6:H35,L6:M35] If Not intersect(Target, Range("Plg")) Is Nothing Then ActiveSheet.Unprotect Else: Exit Sub ActiveSheet.Unprotect For Each c In Plg If Not c.Comment Is Nothing Then With c.Comment.Shape.OLEFormat.Object .AutoSize = True .Font.Name = "Tahoma" .Font.Size = 10 .Font.Bold = False .ShapeRange.Fill.ForeColor.SchemeColor = 42 End With End If Next c
End Sub
Merci par avance pour votre aide
Cordialement
Infogroup
Bonjour.
1. Target n'est défini nulle part.
2. Plg est un objet Range (tout comme Target), tu dois l'employer tel
quel.
Cordialement.
Daniel
Bonjour à toutes et à tous,
j'ai la macro suivante ( qui vient du forum ) et que j'ai adapté pour mettre
en forme des commentaires dans une plage définie.
Problème, j'ai une erreur d'exécution 1004 dans l'instruction :
If Not intersect(Target, Range("Plg")) Is Nothing Then ActiveSheet.Unprotect
Else: Exit Sub
Private Sub Worksheet_Activate()
Dim Plg As Range
Set Plg = [C6:H35,L6:M35]
If Not intersect(Target, Range("Plg")) Is Nothing Then ActiveSheet.Unprotect
Else: Exit Sub
ActiveSheet.Unprotect
For Each c In Plg
If Not c.Comment Is Nothing Then
With c.Comment.Shape.OLEFormat.Object
.AutoSize = True
.Font.Name = "Tahoma"
.Font.Size = 10
.Font.Bold = False
.ShapeRange.Fill.ForeColor.SchemeColor = 42
End With
End If
Next c
Bonjour. 1. Target n'est défini nulle part. 2. Plg est un objet Range (tout comme Target), tu dois l'employer tel quel. Cordialement. Daniel
Bonjour à toutes et à tous,
j'ai la macro suivante ( qui vient du forum ) et que j'ai adapté pour mettre en forme des commentaires dans une plage définie. Problème, j'ai une erreur d'exécution 1004 dans l'instruction : If Not intersect(Target, Range("Plg")) Is Nothing Then ActiveSheet.Unprotect Else: Exit Sub
Private Sub Worksheet_Activate() Dim Plg As Range Set Plg = [C6:H35,L6:M35] If Not intersect(Target, Range("Plg")) Is Nothing Then ActiveSheet.Unprotect Else: Exit Sub ActiveSheet.Unprotect For Each c In Plg If Not c.Comment Is Nothing Then With c.Comment.Shape.OLEFormat.Object .AutoSize = True .Font.Name = "Tahoma" .Font.Size = 10 .Font.Bold = False .ShapeRange.Fill.ForeColor.SchemeColor = 42 End With End If Next c
End Sub
Merci par avance pour votre aide
Cordialement
Infogroup
MichDenis
| If Not Intersect(ActiveCell, Range(Plg.Address)) Is Nothing Then
Si dans cette ligne de code de ta procédure, tu utilises "Target", je te ferai remarquer que Target n'est pas défini comme plage de cellules. C'est ce qui fait planter ta ligne de code.
Attention, dans d'autres procédures événementielles comme par exemple : '------------------------------ Private Sub Worksheet_Change(ByVal Target As Range)
End Sub '------------------------------ Target est défini par l'application dans l'appel de la procédure. Ce n'est pas vrai pour toutes les procédures événementielles. Dans le code suivant, j'ai remplacé "Target" par "ActiveCell" ... je ne sais pas si cela te convient sinon tu devras trouver un moyen de définir la plage de cellules qui te convient !
'------------------------------------------------ Private Sub Worksheet_Activate() Dim Plg As Range Set Plg = [C6:H35,L6:M35] If Not Intersect(ActiveCell, Range(Plg.Address)) Is Nothing Then ActiveSheet.Unprotect Else: Exit Sub ActiveSheet.Unprotect End If For Each c In Plg If Not c.Comment Is Nothing Then With c.Comment.Shape.OLEFormat.Object .AutoSize = True .Font.Name = "Tahoma" .Font.Size = 10 .Font.Bold = False .ShapeRange.Fill.ForeColor.SchemeColor = 42 End With End If Next c
End Sub '------------------------------------------------
"Infogroup" a écrit dans le message de groupe de discussion :
Bonjour à toutes et à tous,
j'ai la macro suivante ( qui vient du forum ) et que j'ai adapté pour mettre en forme des commentaires dans une plage définie. Problème, j'ai une erreur d'exécution 1004 dans l'instruction : If Not intersect(Target, Range("Plg")) Is Nothing Then ActiveSheet.Unprotect Else: Exit Sub
Private Sub Worksheet_Activate() Dim Plg As Range Set Plg = [C6:H35,L6:M35] If Not intersect(Target, Range("Plg")) Is Nothing Then ActiveSheet.Unprotect Else: Exit Sub ActiveSheet.Unprotect For Each c In Plg If Not c.Comment Is Nothing Then With c.Comment.Shape.OLEFormat.Object .AutoSize = True .Font.Name = "Tahoma" .Font.Size = 10 .Font.Bold = False .ShapeRange.Fill.ForeColor.SchemeColor = 42 End With End If Next c
End Sub
Merci par avance pour votre aide
Cordialement
Infogroup
| If Not Intersect(ActiveCell, Range(Plg.Address)) Is Nothing Then
Si dans cette ligne de code de ta procédure, tu utilises "Target", je te ferai
remarquer que Target n'est pas défini comme plage de cellules. C'est ce
qui fait planter ta ligne de code.
Attention, dans d'autres procédures événementielles comme par exemple :
'------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
End Sub
'------------------------------
Target est défini par l'application dans l'appel de la procédure. Ce n'est pas
vrai pour toutes les procédures événementielles. Dans le code suivant,
j'ai remplacé "Target" par "ActiveCell" ... je ne sais pas si cela te convient sinon
tu devras trouver un moyen de définir la plage de cellules qui te convient !
'------------------------------------------------
Private Sub Worksheet_Activate()
Dim Plg As Range
Set Plg = [C6:H35,L6:M35]
If Not Intersect(ActiveCell, Range(Plg.Address)) Is Nothing Then
ActiveSheet.Unprotect
Else: Exit Sub
ActiveSheet.Unprotect
End If
For Each c In Plg
If Not c.Comment Is Nothing Then
With c.Comment.Shape.OLEFormat.Object
.AutoSize = True
.Font.Name = "Tahoma"
.Font.Size = 10
.Font.Bold = False
.ShapeRange.Fill.ForeColor.SchemeColor = 42
End With
End If
Next c
End Sub
'------------------------------------------------
"Infogroup" <Infogroup70@orange.fr> a écrit dans le message de groupe de discussion :
ejwsHAquJHA.3848@TK2MSFTNGP02.phx.gbl...
Bonjour à toutes et à tous,
j'ai la macro suivante ( qui vient du forum ) et que j'ai adapté pour mettre
en forme des commentaires dans une plage définie.
Problème, j'ai une erreur d'exécution 1004 dans l'instruction :
If Not intersect(Target, Range("Plg")) Is Nothing Then ActiveSheet.Unprotect
Else: Exit Sub
Private Sub Worksheet_Activate()
Dim Plg As Range
Set Plg = [C6:H35,L6:M35]
If Not intersect(Target, Range("Plg")) Is Nothing Then ActiveSheet.Unprotect
Else: Exit Sub
ActiveSheet.Unprotect
For Each c In Plg
If Not c.Comment Is Nothing Then
With c.Comment.Shape.OLEFormat.Object
.AutoSize = True
.Font.Name = "Tahoma"
.Font.Size = 10
.Font.Bold = False
.ShapeRange.Fill.ForeColor.SchemeColor = 42
End With
End If
Next c
| If Not Intersect(ActiveCell, Range(Plg.Address)) Is Nothing Then
Si dans cette ligne de code de ta procédure, tu utilises "Target", je te ferai remarquer que Target n'est pas défini comme plage de cellules. C'est ce qui fait planter ta ligne de code.
Attention, dans d'autres procédures événementielles comme par exemple : '------------------------------ Private Sub Worksheet_Change(ByVal Target As Range)
End Sub '------------------------------ Target est défini par l'application dans l'appel de la procédure. Ce n'est pas vrai pour toutes les procédures événementielles. Dans le code suivant, j'ai remplacé "Target" par "ActiveCell" ... je ne sais pas si cela te convient sinon tu devras trouver un moyen de définir la plage de cellules qui te convient !
'------------------------------------------------ Private Sub Worksheet_Activate() Dim Plg As Range Set Plg = [C6:H35,L6:M35] If Not Intersect(ActiveCell, Range(Plg.Address)) Is Nothing Then ActiveSheet.Unprotect Else: Exit Sub ActiveSheet.Unprotect End If For Each c In Plg If Not c.Comment Is Nothing Then With c.Comment.Shape.OLEFormat.Object .AutoSize = True .Font.Name = "Tahoma" .Font.Size = 10 .Font.Bold = False .ShapeRange.Fill.ForeColor.SchemeColor = 42 End With End If Next c
End Sub '------------------------------------------------
"Infogroup" a écrit dans le message de groupe de discussion :
Bonjour à toutes et à tous,
j'ai la macro suivante ( qui vient du forum ) et que j'ai adapté pour mettre en forme des commentaires dans une plage définie. Problème, j'ai une erreur d'exécution 1004 dans l'instruction : If Not intersect(Target, Range("Plg")) Is Nothing Then ActiveSheet.Unprotect Else: Exit Sub
Private Sub Worksheet_Activate() Dim Plg As Range Set Plg = [C6:H35,L6:M35] If Not intersect(Target, Range("Plg")) Is Nothing Then ActiveSheet.Unprotect Else: Exit Sub ActiveSheet.Unprotect For Each c In Plg If Not c.Comment Is Nothing Then With c.Comment.Shape.OLEFormat.Object .AutoSize = True .Font.Name = "Tahoma" .Font.Size = 10 .Font.Bold = False .ShapeRange.Fill.ForeColor.SchemeColor = 42 End With End If Next c
End Sub
Merci par avance pour votre aide
Cordialement
Infogroup
Infogroup
Merci à Jacky, Daniel.C et MichDenis
en fait je ne comprenais pas bien l'utilisation de target, je pensais qu'il représentait toujours la cellule active.
Encore merci à vous trois pour ces précisions
Cdl
Infogroup
"Jacky" a écrit dans le message de news:
Bonjour,
Il n'y a pas d'argument "Target" dans l'événement "Activate()" Bien que je ne comprends pas comment se fait la sélection dans la plage. En remarque avec l'évenement "Change" La syntaxe serait: '------------------------ Private Sub Worksheet_Activate() '*****Private Sub Worksheet_Change(ByVal Target As Range) Dim Plg As Range Set Plg = [C6:H35,L6:M35] If Not Intersect(ActiveCell, Plg) Is Nothing Then '*****If Not Intersect(target, Plg) Is Nothing Then ActiveSheet.Unprotect For Each c In Plg If Not c.Comment Is Nothing Then With c.Comment.Shape.OLEFormat.Object .AutoSize = True .Font.Name = "Tahoma" .Font.Size = 10 .Font.Bold = False .ShapeRange.Fill.ForeColor.SchemeColor = 42 End With End If Next c End If End Sub '----------------------
-- Salutations JJ
"Infogroup" a écrit dans le message de news:
Bonjour à toutes et à tous,
j'ai la macro suivante ( qui vient du forum ) et que j'ai adapté pour mettre en forme des commentaires dans une plage définie. Problème, j'ai une erreur d'exécution 1004 dans l'instruction : If Not intersect(Target, Range("Plg")) Is Nothing Then ActiveSheet.Unprotect Else: Exit Sub
Private Sub Worksheet_Activate() Dim Plg As Range Set Plg = [C6:H35,L6:M35] If Not intersect(Target, Range("Plg")) Is Nothing Then ActiveSheet.Unprotect Else: Exit Sub ActiveSheet.Unprotect For Each c In Plg If Not c.Comment Is Nothing Then With c.Comment.Shape.OLEFormat.Object .AutoSize = True .Font.Name = "Tahoma" .Font.Size = 10 .Font.Bold = False .ShapeRange.Fill.ForeColor.SchemeColor = 42 End With End If Next c
End Sub
Merci par avance pour votre aide
Cordialement
Infogroup
Merci à Jacky, Daniel.C et MichDenis
en fait je ne comprenais pas bien l'utilisation de target, je pensais qu'il
représentait toujours la cellule active.
Encore merci à vous trois pour ces précisions
Cdl
Infogroup
"Jacky" <Dupond@marcel.fr> a écrit dans le message de
news:OClamtquJHA.4364@TK2MSFTNGP03.phx.gbl...
Bonjour,
Il n'y a pas d'argument "Target" dans l'événement "Activate()"
Bien que je ne comprends pas comment se fait la sélection dans la plage.
En remarque avec l'évenement "Change"
La syntaxe serait:
'------------------------
Private Sub Worksheet_Activate()
'*****Private Sub Worksheet_Change(ByVal Target As Range)
Dim Plg As Range
Set Plg = [C6:H35,L6:M35]
If Not Intersect(ActiveCell, Plg) Is Nothing Then
'*****If Not Intersect(target, Plg) Is Nothing Then
ActiveSheet.Unprotect
For Each c In Plg
If Not c.Comment Is Nothing Then
With c.Comment.Shape.OLEFormat.Object
.AutoSize = True
.Font.Name = "Tahoma"
.Font.Size = 10
.Font.Bold = False
.ShapeRange.Fill.ForeColor.SchemeColor = 42
End With
End If
Next c
End If
End Sub
'----------------------
--
Salutations
JJ
"Infogroup" <Infogroup70@orange.fr> a écrit dans le message de news:
ejwsHAquJHA.3848@TK2MSFTNGP02.phx.gbl...
Bonjour à toutes et à tous,
j'ai la macro suivante ( qui vient du forum ) et que j'ai adapté pour
mettre en forme des commentaires dans une plage définie.
Problème, j'ai une erreur d'exécution 1004 dans l'instruction :
If Not intersect(Target, Range("Plg")) Is Nothing Then
ActiveSheet.Unprotect Else: Exit Sub
Private Sub Worksheet_Activate()
Dim Plg As Range
Set Plg = [C6:H35,L6:M35]
If Not intersect(Target, Range("Plg")) Is Nothing Then
ActiveSheet.Unprotect Else: Exit Sub
ActiveSheet.Unprotect
For Each c In Plg
If Not c.Comment Is Nothing Then
With c.Comment.Shape.OLEFormat.Object
.AutoSize = True
.Font.Name = "Tahoma"
.Font.Size = 10
.Font.Bold = False
.ShapeRange.Fill.ForeColor.SchemeColor = 42
End With
End If
Next c
en fait je ne comprenais pas bien l'utilisation de target, je pensais qu'il représentait toujours la cellule active.
Encore merci à vous trois pour ces précisions
Cdl
Infogroup
"Jacky" a écrit dans le message de news:
Bonjour,
Il n'y a pas d'argument "Target" dans l'événement "Activate()" Bien que je ne comprends pas comment se fait la sélection dans la plage. En remarque avec l'évenement "Change" La syntaxe serait: '------------------------ Private Sub Worksheet_Activate() '*****Private Sub Worksheet_Change(ByVal Target As Range) Dim Plg As Range Set Plg = [C6:H35,L6:M35] If Not Intersect(ActiveCell, Plg) Is Nothing Then '*****If Not Intersect(target, Plg) Is Nothing Then ActiveSheet.Unprotect For Each c In Plg If Not c.Comment Is Nothing Then With c.Comment.Shape.OLEFormat.Object .AutoSize = True .Font.Name = "Tahoma" .Font.Size = 10 .Font.Bold = False .ShapeRange.Fill.ForeColor.SchemeColor = 42 End With End If Next c End If End Sub '----------------------
-- Salutations JJ
"Infogroup" a écrit dans le message de news:
Bonjour à toutes et à tous,
j'ai la macro suivante ( qui vient du forum ) et que j'ai adapté pour mettre en forme des commentaires dans une plage définie. Problème, j'ai une erreur d'exécution 1004 dans l'instruction : If Not intersect(Target, Range("Plg")) Is Nothing Then ActiveSheet.Unprotect Else: Exit Sub
Private Sub Worksheet_Activate() Dim Plg As Range Set Plg = [C6:H35,L6:M35] If Not intersect(Target, Range("Plg")) Is Nothing Then ActiveSheet.Unprotect Else: Exit Sub ActiveSheet.Unprotect For Each c In Plg If Not c.Comment Is Nothing Then With c.Comment.Shape.OLEFormat.Object .AutoSize = True .Font.Name = "Tahoma" .Font.Size = 10 .Font.Bold = False .ShapeRange.Fill.ForeColor.SchemeColor = 42 End With End If Next c