Commentaire - ajuster automatiquement la taille

herve80

XLDnaute Occasionnel
Bonjour,

D'abord la flatterie : vous êtes les meilleurs, bla bla bla.

Sérieusement, pourriez-vous (svp) adapter la "macro" suivante pour que le cadre s'adapte automatiquement au texte tapé (pour ne pas devoir agrandir le cadre après, histoire d'afficher tout le texte)

Sub comm()
On Error Resume Next
Dim cell As Range
Dim Touches As String
For Each cell In Selection
Selection.Font.Bold = True
Selection.Font.ColorIndex = 3
cell.AddComment
cell.Comment.Visible = True
cell.Comment.Text Text:="VIDE CHARGE"
Application.DisplayCommentIndicator = xlCommentIndicatorOnly
Next
End Sub

Merci et bonne journée à tous ;)
 

lik

XLDnaute Nouveau
macro doublons

Salut !!! j'ai une macro pour détecter les doublons et les colorier, quand on l'éxecute on obtient un inputbox dans lequel on définit la plage concernée. Mon problème est que cette plage est en fait 3 colonnes dans 3 feuilles différentes. Comment définir ces plages pour colorier les doublons sur les différents onglets ? voici le code :

Sub MarqueLesDoublons()
Dim Plage As Range, i&, Cell As Range, Rng As Range

On Error Resume Next
Set Plage = Application.InputBox("worksheets", Type:=8)
If IsEmpty(Plage) Then Exit Sub

Application.ScreenUpdating = False

For Each Cell In Plage
For i = 1 To Plage.Count
Set Rng = Cell.Offset(i)
If Rng <> "" And Rng = Cell Then
Cell.Interior.ColorIndex = 3
Rng.Interior.ColorIndex = 3
Exit For
End If
Next i
Next Cell

End Sub
 

noviceAG

XLDnaute Impliqué
Re : Commentaire - ajuster automatiquement la taille

Bonjour hervé, le Forum,

peut être ceci sorti de mes archives :

'Possibilité Largeur/Hauteur FIXE en macro évènementielle :
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim CommentObj As Comment
For Each CommentObj In Me.Comments
With CommentObj.Shape
.Height = 25
.Width = 250
End With
Next
End Sub

'Possibilité Largeur/Hauteur VARIABLE (AutoSize) :
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim CommentObj As Comment

For Each CommentObj In Me.Comments
CommentObj.Shape.TextFrame.AutoSize = True
Next
End Sub

Amicalement votre
 

vbacrumble

XLDnaute Accro
Re : Commentaire - ajuster automatiquement la taille

Bonjour à tous

EDITION: une autre mouture
Code:
Sub essaicommentaires()
Dim Cell As Range
Application.ScreenUpdating = False
For Each Cell In Selection
With Cell
    With .Font
        .Bold = True
        .ColorIndex = 3
    End With
    .AddComment
End With
Next
For Each Cell In Selection.SpecialCells(xlCellTypeComments)
    With Cell.Comment
        .Text Text:="VIDE CHARGE"
        .Shape.TextFrame.AutoSize = True
    End With
Next
With Application
    .DisplayCommentIndicator = xlCommentIndicatorOnly
    .ScreenUpdating = True
End With
End Sub

En réutilisant le code de noviceAG

Code:
Sub comm()
On Error Resume Next
Dim cell As Range
Dim CommentObj As Comment
With Selection.Font
    .Bold = True
    .Font.ColorIndex = 3
End With
For Each cell In Selection
cell.AddComment
Next
For Each CommentObj In ActiveSheet.Comments
    CommentObj.Visible = True
    CommentObj.Text Text:="VIDE CHARGE"
    CommentObj.Shape.TextFrame.AutoSize = True
Next
'Application.DisplayCommentIndicator = xlCommentIndicatorOnly
End Sub

A+
 
Dernière édition:

Statistiques des forums

Discussions
312 233
Messages
2 086 466
Membres
103 225
dernier inscrit
PAPA ALIOUNE HANE