A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data
Hi Brad,
Thank you for posting in Microsoft Community.
Regarding to your description and based on my understanding, the reason that not running is a syntax error in VBA.
To clarify:
In VBA, an IF statement can be written in two ways:
- Single line IF:
If condition Then action End If
- (e.g., If Not cmt Is Nothing Then cmt.Shape.TextFrame.AutoSize = True)
- Multi-line IF: With Then on the first line, followed by the action on subsequent lines, and ending with End If.
Your code combines these two formats: If Not cmt Is Nothing Then cmt.Shape.TextFrame.AutoSize = True and then immediately End If. This may create a syntax error that stops the code from running correctly. Therefore, I suggest a corrected version of the macro:
Sub AutosizeComments()
Dim cmt As Comment, cell As Range
On Error Resume Next
For Each cell In ActiveSheet.UsedRange
Set cmt = cell.Comment
If Not cmt Is Nothing Then cmt.Shape.TextFrame.AutoSize = True
Next cell
End Sub
Additional note: If, after running the macro, you still can't grab the grips or resize a specific comment, it may be extremely small or positioned off-screen. Try zooming out significantly or using Go To Special feature (F5 > Special > Objects) to locate and adjust it.
I hope this helps. Please dont hesistate t let me know if you have any furterh question or concern.
Best Regards,
Mia - MSFT | Microsoft Community Support Specialist.