+ Reply to Thread
Results 1 to 4 of 4

PLEAS HELP! Newby Needs help Populating Cell w/ Application.usern

  1. #1
    zulfer7
    Guest

    PLEAS HELP! Newby Needs help Populating Cell w/ Application.usern

    Sub Populate_Username

    Dim Text as String

    Range("A2").Select
    text = application.username

    This does not populate the application.username at cell A2 so what needs to
    be done to this code?

  2. #2
    Nick Hodge
    Guest

    Re: PLEAS HELP! Newby Needs help Populating Cell w/ Application.usern

    Range("A2").Value=Application.UserName

    This will put in the username in Tools>Options...>General, NOT the network
    or machine logon

    --
    HTH
    Nick Hodge
    Microsoft MVP - Excel
    Southampton, England
    www.nickhodge.co.uk
    [email protected]HIS


    "zulfer7" <[email protected]> wrote in message
    news:[email protected]...
    > Sub Populate_Username
    >
    > Dim Text as String
    >
    > Range("A2").Select
    > text = application.username
    >
    > This does not populate the application.username at cell A2 so what needs
    > to
    > be done to this code?




  3. #3
    Steve Wright
    Guest

    Re: PLEAS HELP! Newby Needs help Populating Cell w/ Application.usern

    The following will put the windows username in a cell. You will need to
    change the sheetnames to suit your workbook and fiddle with the rest of the
    code to make it do what you want.

    Steve


    -------------------------------
    Option Explicit


    Private Declare Function GetUserNameAPI Lib "advapi32.dll" Alias
    "GetUserNameA" (ByVal lpBuffer As String, _
    nSize As Long)
    As Long

    Public Function GetUserName() As String
    Dim sBuffer As String
    Dim lSize As Long
    Dim lRV As Long

    lSize = 255
    sBuffer = String(lSize, &H0)

    lRV = GetUserNameAPI(sBuffer, lSize)

    If lRV <> 0 Then
    GetUserName = Left(sBuffer, lSize - 1) ' -1 to remove trailing null
    character
    Else
    GetUserName = ""
    End If
    End Function

    Sub EnterUser()
    Worksheets("Use Log").Visible = True
    Worksheets("Use Log").Select
    Range("a1").Select
    Range("A65536").End(xlUp).Offset(1, 0).Select
    ActiveCell.Value = GetUserName
    ActiveCell.Offset(0, 1).Value = Now
    Worksheets("Use Log").Visible = False
    Worksheets("Main").Select
    End Sub

    --------------------------------------

    "Nick Hodge" <[email protected]> wrote in message
    news:[email protected]...
    > Range("A2").Value=Application.UserName
    >
    > This will put in the username in Tools>Options...>General, NOT the network
    > or machine logon
    >
    > --
    > HTH
    > Nick Hodge
    > Microsoft MVP - Excel
    > Southampton, England
    > www.nickhodge.co.uk
    > [email protected]HIS
    >
    >
    > "zulfer7" <[email protected]> wrote in message
    > news:[email protected]...
    >> Sub Populate_Username
    >>
    >> Dim Text as String
    >>
    >> Range("A2").Select
    >> text = application.username
    >>
    >> This does not populate the application.username at cell A2 so what needs
    >> to
    >> be done to this code?

    >
    >




  4. #4
    zulfer7
    Guest

    Re: PLEAS HELP! Newby Needs help Populating Cell w/ Application.u

    THIS WAS PERFECT, Thanks!

    "Nick Hodge" wrote:

    > Range("A2").Value=Application.UserName
    >
    > This will put in the username in Tools>Options...>General, NOT the network
    > or machine logon
    >
    > --
    > HTH
    > Nick Hodge
    > Microsoft MVP - Excel
    > Southampton, England
    > www.nickhodge.co.uk
    > [email protected]HIS
    >
    >
    > "zulfer7" <[email protected]> wrote in message
    > news:[email protected]...
    > > Sub Populate_Username
    > >
    > > Dim Text as String
    > >
    > > Range("A2").Select
    > > text = application.username
    > >
    > > This does not populate the application.username at cell A2 so what needs
    > > to
    > > be done to this code?

    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1