Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Mise en forme de commentaires

4 réponses
Avatar
Infogroup
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

4 réponses

Avatar
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


Avatar
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


Avatar
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
Avatar
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