commentaire sous condition

pascal21

XLDnaute Barbatruc
Code:
With Sheets("tableau de bord")
Dim Cel As Range
[COLOR="Red"]For Each Cel In Range("j6:j121;m123:m238;k357:k572")[/COLOR]
With Cel
.ClearComments
If .Value > 0 And .Value <= 50 Then
With .AddComment
.Text Text:="Attention Prevoir vidange dans " & Cel & " heures"
 .Visible = True
.Shape.TextFrame.AutoSize = True
 End With
ElseIf .Value < 0 Then
With .AddComment
 .Text Text:="Attention depassement vidange de  " & Cel & " heures"
 .Visible = True
 With .Shape
 .TextFrame.AutoSize = True
 With .OLEFormat.Object
 With .Font
 .Name = "Arial"
.Size = 10
 .ColorIndex = 3
 .Bold = True
 End With
 End With
 End With
 End With
End If
 End With
 Next Cel
 End With
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
       , AllowInsertingHyperlinks:=True, AllowSorting:=True, AllowFiltering:= _
       True
bonjour à tous
avec ce code dans worksheet activate j'ai un commentaire qui s'affiche sous condition
mais j'ai une erreur (ligne rouge)
quand il n'y a pas de commentaire dans la zone indiquée
comment rajouter une condition du genre
if Range("j6:j121;m123:m238;k357:k572") = pas de commentaire then exit sub
en début de code
merci
 

Pierrot93

XLDnaute Barbatruc
Re : commentaire sous condition

Bonjour Pascal

sur la ligne en question,

Code:
For Each Cel In Range("j6:j121;m123:m238;k357:k572")

remplace peut être les ; par des ,

Code:
For Each Cel In Range("j6:j121,m123:m238,k357:k572")

bonne journée
@+

Edition : bonjour Job
 

pascal21

XLDnaute Barbatruc
Re : commentaire sous condition

bonjour pierrot, ; Job
tiens!!! bin ça aussi je ne comprends pas, un coup il faut mettre des , le coup d'après c'est des ; qu'il réclame
je rectifie merci
edit c'est bon ça marche
 
Dernière édition:

Discussions similaires

Statistiques des forums

Discussions
312 842
Messages
2 092 721
Membres
105 517
dernier inscrit
Freddy93