Enter Comment by Code

mutrus

Board Regular
Joined
Sep 10, 2002
Messages
80
When a comment is added to a cell it contains the users login by default.

I wish to add comments by using code. How can I assign the users login to a variable
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
> I wish to add comments by using code.

Range("A1").AddComment "Juan Pablo"

> How can I assign the users login to a variable

MyVar = Application.UserName
 
Upvote 0
On 2002-09-11 20:54, mutrus wrote:
When a comment is added to a cell it contains the users login by default.

I wish to add comments by using code. How can I assign the users login to a variable
Actually it doesn't add the users login name.
It meely uses the User name from the Options droplist in Excel, which anyone can change.

If you want the login user name then thius may help;

<pre/>
Declare Function WNetGetUser Lib "mpr.dll" _
Alias "WNetGetUserA" ( _
ByVal lpName As String, _
ByVal lpUserName As String, _
lpnLength As Long) As Long

Function GetName() As String
Dim strUserName As String
strUserName = Space(255)
WNetGetUser "", strUserName, 255
GetName = Trim(strUserName)
End Function
</pre>
 
Upvote 0
Juan Pable G - thanks that works

Ivan F Foala - your reply does more than I asked but has now prompted me to think about that approach

Both replies thanks
 
Upvote 0
Ivan - I just realised what your logo was. No wonder I got a fast reply to my post.

Cheers from a fellow Kiwi

Go the Warriors
 
Upvote 0
On 2002-09-12 01:31, mutrus wrote:
Ivan - I just realised what your logo was. No wonder I got a fast reply to my post.

Cheers from a fellow Kiwi

Go the Warriors

Go the Warriors !
Your IP is the same as fellow Mrexcel MVP Paddy
Where are you ? Wellington ?
 
Upvote 0

Forum statistics

Threads
1,222,900
Messages
6,168,926
Members
452,227
Latest member
sam1121

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