Comments don't stay where they belong

kajero52

New Member
Joined
Jan 6, 2020
Messages
3
Office Version
  1. 2007
Platform
  1. Windows
I have no idea how to write complicated macros so I try to find something on the Internet I can use. So far I haven't found much. Maybe some of you gurus could help me? Thanks for any assistance you can give me.

I have a spreadsheet that has 945 rows. It lists all the books since 2013 whether or not I have read them. Most of the rows have comments. When I try to view the comments sometimes they are way far away from the cell they are attached to. See example below.

1647722329263.png


I did find a macro o n YouTube that keeps the macro with the cell but then I can't read the comments easily
Sub ResetComments()
'Excel 10 Tutorial
Dim pComment As Comment
For Each pComment In Application.ActiveSheet.Comments
pComment.Shape.Top = pComment.Parent.Top + 5
pComment.Shape.Left = pComment.Parent.Offset(0, 1).Left + 5
Next
End Sub

This sometimes happens. Is there a way to make all the comments views the same size for easier reading. It really isn't necessary to have all the comment displayed at once but when the comment cross so many columns it is hard to read.
1647722969574.png
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Is there a way to make all the comments views the same size for easier reading. It really isn't necessary to have all the comment displayed at once but when the comment cross so many columns it is hard to read.
You can reduce the width of the comments and increase their height manually or via code (similar to the code you have above)
 
Upvote 0
Along the lines suggested by @Jaafar Tribak you could give this adaptation a try. It tries to auto-fit each comment, while setting a maximum value for the width of the comment box
Experiment with changing the 'Const' line value and see if you can find something that suits your needs.

VBA Code:
Sub ResetComments_v2()
  Dim pComment As Comment
  Dim CmtArea As Long
 
  Const MaxWidth As Long = 300  '<- Try changing this number
 
  For Each pComment In Application.ActiveSheet.Comments
    With pComment.Shape
      .Top = pComment.Parent.Top + 5
      .Left = pComment.Parent.Offset(0, 1).Left + 5
      .TextFrame.AutoSize = True
      If .Width > MaxWidth Then
        CmtArea = .Width * .Height
        .Width = MaxWidth
        .Height = CmtArea / MaxWidth * 1.1
      End If
    End With
  Next pComment
End Sub
 
Upvote 0

Forum statistics

Threads
1,217,138
Messages
6,134,852
Members
449,893
Latest member
des378

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