VBA code- insert comment box

j4ymf

Well-known Member
Joined
Apr 28, 2003
Messages
743
Office Version
  1. 365
Platform
  1. Windows
Good Morning all
a few years ago in an old job some one helped me create this piece of code which adds a comment box once someone adds anything to a cell
i'm getting a run time error

can you please help
thank you Jason


error:
Target.Comment.Shape.TextFrame.Characters(1, Len(Application.UserName)).Font.Bold = True






<code>
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
'changes the cells to UPPERCASE
If Intersect(Target, Range("A1:AH100")) Is Nothing Then Exit Sub

Application.EnableEvents = False
Target = UCase(Target)
Application.EnableEvents = True

'Adds a comment box to each cell when somthing is added to the cell

If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Not Target.Comment Is Nothing Then Target.Comment.Delete
Target.AddComment Text:=Application.UserName & vbNewLine & Date & vbNewLine & Time
Target.Comment.Shape.TextFrame.Characters(1, Len(Application.UserName)).Font.Bold = True


End Sub
</code>
 
Last edited:

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Your code does not fail with Office 365

I suspect it is something else in your workbook causing the problem
To eliminate the possibility that this is an Excel version problem etc, test the code yourself in a NEW workbook and let us know the result of that test
 
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