Current Username into a cell

alexg

New Member
Joined
Sep 25, 2006
Messages
4
I Am Generating a spreadsheet and need to use the current logged in username as a Variable quantity in a lookup - Does anyone know how i can get the curretn log in users username to appear in a cell in excel??

Kind reagrds

Alex
 
Hi,

I have entered this into mywrkbook and it still does not give me my username...

Any ideas why?

Save the workbook, then close it and re-open it.
 
Upvote 0

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hello,

i think, and correct me if i'm wrong, nut it comes from the PC not excelas such, we use xp and on a network and my login name is the same as =environ(username).

Doh! you were right it picks from my login name

Thanks for this, could be very useful
 
Upvote 0
Related point - to retrieve the full name of the user, I use the following code. It retrieves details from the Outlook Address Book...

Code:
        Dim myOlApp, myNameSpace As Object
        Dim Full_name, First_Name, Surname, User As String
        
        Set myOlApp = CreateObject("Outlook.Application")
        Set myNameSpace = myOlApp.GetNameSpace("MAPI")
            
        Full_name = myNameSpace.CurrentUser.Name
    
        First_Name = Right(Full_name, Len(Full_name) - WorksheetFunction.Search(",", Full_name) - 1)
        Surname = Left(Full_name, WorksheetFunction.Search(",", Full_name) - 1)
        User = First_Name & " " & Surname
 
Upvote 0
I have entered this into mywrkbook and it still does not give me my username...
Any ideas why?
Start Windows Explorer, click the + next to the C: drive, click the + next to Documents and Settings

In the next level below Documents and Settings you should see sub-folders like Administrator, All Users, Default User, etc.

One of the sub-folders near the button of that section will have the username in it. If it isn't your name then it is however the computer was setup as when Windows was loaded. If this is your computer as a stand-alone, then you should know (and recognize) what name it has. If it is a work computer on a network, then it should be your logon name. If it is a work computer on a network and you can't figure out the username, ask your IT personnel.
 
Upvote 0
Hi

I tried your code and it comes up with an error message saying:

Invalid Ouside procedure

Highlights the first word on this row

Code:
  Set myOlApp = CreateObject("Outlook.Application")
 
Upvote 0

Forum statistics

Threads
1,215,026
Messages
6,122,738
Members
449,094
Latest member
dsharae57

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