Created
February 1, 2022 13:20
-
-
Save z720/1a5ece32d6174ac7b49fae5c9e8f0c7c to your computer and use it in GitHub Desktop.
Excel Macro : Reset comments (position and size)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Attribute VB_Name = "ResetComments" | |
Sub ResetComments() | |
' ADD TO %appdata%\Microsoft\Excel\XLSTART\PERSONAL.XLSB | |
Dim pComment As Comment | |
Dim maxWidth As Integer | |
maxWidth = 250 | |
For Each pComment In Application.ActiveSheet.Comments | |
pComment.Shape.Top = pComment.Parent.Top + 15 | |
pComment.Shape.Left = pComment.Parent.Offset(0, 1).Left + 25 | |
pComment.Shape.TextFrame.AutoSize = True | |
If pComment.Shape.Width > maxWidth Then | |
Dim area As Long | |
area = pComment.Shape.Height * pComment.Shape.Width | |
pComment.Shape.Height = area / maxWidth | |
pComment.Shape.Width = maxWidth | |
End If | |
Next | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment