vba to position comment boxes not working

cjcass

Well-known Member
Joined
Oct 27, 2011
Messages
683
Office Version
  1. 2016
Platform
  1. Windows
Hi,
I have the following vba macro to re-position comment boxes on a worksheet but it's having no effect, would anyone have any ideas as to why that could be?
Many thanks,
VBA Code:
Sub ResetComments()
    
    Dim cmt As Comment
    
    For Each cmt In Sheet1.Comments
        cmt.Shape.Top = cmt.Parent.Top + 10
        cmt.Shape.Left = _
            cmt.Parent.Offset(0, 1).Left + 5
    Next
    
End Sub
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
That works for me.
Are you using the old style comments or the new threaded comments?
Is the code looking at the correct sheet?
 
Upvote 0
Hi, thanks for responding.
It was 'ActiveSheet' so I changed it to 'Sheet1' to see if that made a difference.
Re. threaded comments - am using Excel 2016, the comments are generated from a macro using 'AddComment', if that helps in any way?
 
Upvote 0
What is the name of the sheet you want this to work on, or do you want it to work on the active sheet?
 
Upvote 0
In that case use
VBA Code:
For Each cmt In ActiveSheet.Comments
 
Upvote 0
That's what I had previously to Sheet1, doesn't make any difference.
 
Upvote 0
Are the comments always visible, or just on mouse over?
 
Upvote 0
on mouse over.
after I run this code there is no change to the comment box positions
 
Upvote 0
That only affects the position of the comment if it's permanently visible.
Not sure it's possible to change the position of the comment when displayed via mouse over.
 
Upvote 0

Forum statistics

Threads
1,223,907
Messages
6,175,301
Members
452,633
Latest member
DougMo

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