Notes (aka Comments) VBA to change existing comments to same font size

Ironman

Well-known Member
Joined
Jan 31, 2004
Messages
1,069
Office Version
  1. 365
Platform
  1. Windows
Hi

I have a number of notes (Microsoft 365 term for Comments) that contain different font sizes.

Is it possible to change all of these to font size 7 using VBA?

I have tried inserting
VBA Code:
.Font.Size = 7
in some existing code as below, that resizes and relocates notes boxes and it errored 438 "Object doesn't support this property or method".
VBA Code:
Sub AutosizeAndRelocateComments()
Application.ScreenUpdating = False
Dim x As Range, y As Long
For Each x In Cells.SpecialCells(1)
Select Case True
Case Len(x.NoteText) <> 0
With x.Comment
.Font.Size = 7
.Shape.TextFrame.AutoSize = True
If .Shape.Width > 250 Then
y = .Shape.Width * .Shape.Height
.Shape.ScaleHeight 0.75, msoFalse, msoScaleFromTopLeft
.Shape.ScaleWidth 1#, msoFalse, msoScaleFromTopLeft
End If
End With
End Select
Next x

Dim cmt As Comment
For Each cmt In ActiveSheet.Comments
   cmt.Shape.Top = cmt.Parent.Top + 5
   cmt.Shape.Left = _
      cmt.Parent.Offset(0, 1).Left + 5
Next
Application.ScreenUpdating = True
End Sub

Thanks!
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
I found some code online that does the trick and added it below the code above
VBA Code:
Dim Cell As Range  ' reduces font size to 7 (can't be done by default without changing font size for cells)
For Each Cell In Cells.SpecialCells(1)
If Not Cell.Comment Is Nothing Then
With Cell.Comment.Shape.TextFrame.Characters.Font
.Size = 7
End With
End If
Next Cell
End Sub
I tried inserting it into the above but it kept erroring. If somebody is able to do this, that would be appreciated, thank you.
 
Upvote 0
In your original code change
VBA Code:
.Font.Size = 7
to
VBA Code:
.Shape.TextFrame.Characters.Font.Size = 7
 
Upvote 0
Solution
Ahhh that's great Fluff, thanks ever so much, as ever.
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

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