Excel comments appear only as a thin black line and I cannot access the comments via the edit function

Tom Woodford

New Member
Joined
Dec 14, 2013
Messages
10
I have a budget worksheet that I have been using for about 7-8 years, it is large and there are many comments in it.
Last year the comments were all over the place and I found, installed, and used a VBA command to bring them back in line and it worked great.
Well I had to do some serious rearranging this year and they were all over the place again and many were appearing only as a thin black line that I can not seem to
do anything with at all. I found another command that purported to fix this and it runs but it is not resolving anything for me. it follows below.

'==========>>
Option Explicit

'--------->>
Public Sub Tester()
Dim WB As Workbook
Dim SH As Worksheet
Dim Rng As Range, rCell As Range

Set WB = ActiveWorkbook

For Each SH In WB.Worksheets
On Error Resume Next
Set Rng = SH.Cells.SpecialCells(xlCellTypeComments)
On Error GoTo 0

If Not Rng Is Nothing Then
For Each rCell In Rng.Cells
With rCell.Comment.Shape
.Left = rCell.Left + rCell.Width
.Top = rCell.Top
End With
Next rCell
End If
Next SH
End Sub
'<<=========
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Try this:

Rich (BB code):
Public Sub Tester()
  Dim WB As Workbook
  Dim SH As Worksheet
  Dim Rng As Range, rCell As Range
 
  Set WB = ActiveWorkbook
 
  For Each SH In WB.Worksheets
    On Error Resume Next
    Set Rng = SH.Cells.SpecialCells(xlCellTypeComments)
    On Error GoTo 0
   
    If Not Rng Is Nothing Then
      For Each rCell In Rng.Cells
        With rCell.Comment.Shape
          .Left = rCell.Left + rCell.Width + 5
          .Top = rCell.Top
          .TextFrame.AutoSize = True
        End With
      Next rCell
    End If
  Next SH
End Sub
 
Upvote 0
Thanks but I got the following error
1674781993976.png
 
Upvote 0
Try this:

VBA Code:
Sub fit_comments()
  Dim sh As Worksheet
  Dim cmt As Comment
  
  For Each sh In ActiveWorkbook.Sheets
    For Each cmt In sh.Comments
      With cmt.Shape
        .Left = cmt.Parent.Left + cmt.Parent.Width + 5
        .Top = cmt.Parent.Top
        .TextFrame.AutoSize = True
      End With
    Next
  Next
End Sub
 
Upvote 0
Something in one of your sheets has a problem.
Maybe an object in one of your sheets doesn't accept the update, because in my tests all comments are updated.

If you know how to run the macro in debug mode, that is, step by step by pressing the F8 key, then run the following macro.
The macro will select each sheet, then select each comment and apply the update to it. When the macro stops it analyzes which is the sheet and which object is selecting or which object the macro stopped.


VBA Code:
Sub fit_comments()
  Dim sh As Worksheet
  Dim cmt As Comment
  
  For Each sh In ActiveWorkbook.Sheets
    sh.Select
    For Each cmt In sh.Comments
      With cmt.Shape
        .Select
        .Left = cmt.Parent.Left + cmt.Parent.Width + 5
        .Top = cmt.Parent.Top
        .TextFrame.AutoSize = True
      End With
    Next
  Next
End Sub

----- --
Or you can avoid the error with the following, if there is an object with problems then it will be ignored, but all other comments will be adjusted:
VBA Code:
Sub fit_comments_2()
  Dim sh As Worksheet
  Dim cmt As Comment
  
  On Error Resume Next
  For Each sh In ActiveWorkbook.Sheets
    For Each cmt In sh.Comments
      With cmt.Shape
        .Left = cmt.Parent.Left + cmt.Parent.Width + 5
        .Top = cmt.Parent.Top
        .TextFrame.AutoSize = True
      End With
    Next
  Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,323
Members
449,077
Latest member
jmsotelo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top