User Name Value

MikeG

Well-known Member
Joined
Jul 4, 2004
Messages
845
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
In Excel, when someone adds a comment to a cell, then Excel starts the comment with the name of the user, followed by a ":"

Does anyone know how I can read that name into a variable so that I can use it in VBA? I guess it is based on the User Account name.

Thanks,

Mike
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
You could use the Author from the content, like so

Code:
Sub getCommentName()
Dim commentContent As String
commentContent = Range("A1").Comment.Author
MsgBox commentContent
End Sub
 
Upvote 0
For the current user:
Code:
MsgBox Application.Username
 
Last edited:
Upvote 0
I believe that this is where Excel finds the user name to add to comments
Code:
MsgBox ThisWorkbook.BuiltInDocumentProperties("Author").Value
 
Upvote 0
Thanks folks.

I now have the username value in my macro.

MikeG
 
Upvote 0
When I changed the Application.Username, new comments used that but ThisWorkbook.BuiltInDocumentProperties("Author").Value showed the previous value.
 
Upvote 0

Forum statistics

Threads
1,224,532
Messages
6,179,388
Members
452,908
Latest member
MTDelphis

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