Auto comment Box

LanceLance

Board Regular
Joined
Feb 4, 2009
Messages
60
Hi all,
Looking for some help on Comment boxes

I would like to auto position all comment boxes to setlocation closest to cell.

e.g.
All comments to be placed N1:NN9 (Top of sheet)
So if a comment was entered in cell BH33 or BH 11, itwould automatically get re positioned between to BH1:BH9.


I have been using:
Sub ResetComments()
Dim pComment As Comment
For Each pComment InApplication.ActiveSheet.Comments
pComment.Shape.Top = pComment.Parent.Top + 100
pComment.Shape.Left = pComment.Parent.Offset(0, 1).Left + 100
Next
End Sub

But his only moves comment boxed by offset of 100 and notto desired location, and no good with the amount of rows I have in sheet.

Second part of my issue is to ensure comments do not overlap.
I am using following to:
SubComments_AutoSize()
Dim MyComments AsComment
Dim lArea As Long
For EachMyComments In ActiveSheet.Comments
With MyComments
.Shape.TextFrame.AutoSize = True
If .Shape.Width > 300 Then
lArea = .Shape.Width * .Shape.Height
.Shape.Width = 200
' An adjustment factor of 1.1 seems towork ok.
.Shape.Height = (lArea / 200) * 1.1
End If
End With
Next ' comment
End Sub

To resize but, unable to ensure no comment overlap.

Any Help appreciated.

Regards

Lance
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Code updated to:


Sub Comments_AutoSize()
Dim pComments As Comment
Dim lArea As Long
For Each pCommentsIn ActiveSheet.Comments
With pComments
.Shape.TextFrame.AutoSize = True
If .Shape.Width> 300 Then
lArea =.Shape.Width * .Shape.Height
.Shape.Width =200
.Shape.Height =(lArea / 200) * 1.2
End If
End With
Next
For Each pComment In Application.ActiveSheet.Comments
pComment.Shape.Top= pComment.Parent.Top - 10000
pComment.Shape.Left= pComment.Parent.Offset(0, 1).Left + 1
Next
End Sub


Although still unable to manage multiple comment box overlap??
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,184
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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