change text box size for a range of cells...

sadams1

Board Regular
Joined
Aug 19, 2006
Messages
221
I have the following to change the comment box size for one cell as follows:

Sub Comments_Formatonecell()

ActiveCell.Comment.Shape.Width = 540
ActiveCell.Comment.Shape.Height = 150

End Sub



Then this to do the same for all cells:

Sub Comments_Format()
Dim cmt As Comment
For Each cmt In ActiveSheet.Comments
cmt.Shape.Width = 800
cmt.Shape.Height = 450

Next cmt
End Sub




Is is possible to do the same for an active range?
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Hi

I guess that by an active range you mean a selected range.

Select a range and try:

Code:
Sub Comments_Format()
Dim r As Range

For Each r In Selection
    If Not r.Comment Is Nothing Then
        With r.Comment.Shape
            .Width = 800
            .Height = 450
        End With
    End If
Next r
End Sub
 
Upvote 0
Hi

I guess that by an active range you mean a selected range.

Select a range and try:

Code:
Sub Comments_Format()
Dim r As Range

For Each r In Selection
    If Not r.Comment Is Nothing Then
        With r.Comment.Shape
            .Width = 800
            .Height = 450
        End With
    End If
Next r
End Sub


SWEET! Many thanks!
On a similar note, is it possible to do something with textboxes like this? All the stuff I found dealt with autosizing to text. I'd like to active a textbox & have a macro that will make a specific size.
Thanks again!
 
Upvote 0

Forum statistics

Threads
1,223,238
Messages
6,170,939
Members
452,368
Latest member
jayp2104

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