this is some code I have posted before, pass it a computer name or IP address, set it up as a user defined function and reference it in a cell
Public Function GetUserName(HostName As String)
'
' Returns the Username from the HostName for the computer.
'
' Author Unknown
' Mods Jim Ward, 25 March 2008
' Original version was to return the MAC address from the output text from
' a shell of nbtstat.
' This version uses a more elegent method to extract out the <03> record as a
' single line to the new output file, file is then read in first part extracted
' and file deleted.
'
' This is slow by nature as in a couple of seconds to run it for each hostname
' so if you have many to find and copy the function down be warned as it will
' not give instant results.
'
Dim SH As Object
Dim FSO As Object
Dim TS As Object
Dim Data As String
Dim UserName As String
'
On Error GoTo ErrorHandler
'
'****
' create a scripting shell object, and run our command through it
' if it is an IP address use -A, else for computer name use -a
'****
'
Set SH = CreateObject("wscript.shell")
If InStr(HostName, ".") Then
SH.Run "%comspec% /c nbtstat -A " _
& HostName & " | FIND ""<03>"" | FIND /I /V " & Chr(34) & HostName & Chr(34) & " > c:\nbuser.txt", 0, True
Else
SH.Run "%comspec% /c nbtstat -a " _
& HostName & " | FIND ""<03>"" | FIND /I /V " & Chr(34) & HostName & Chr(34) & " > c:\nbuser.txt", 0, True
End If
Set SH = Nothing
'Stop
'
'****
' open up the results file, should have a single line, extract the username
'****
'
Set FSO = CreateObject("scripting.filesystemobject")
Set TS = FS
pentextfile("c:\nbuser.txt") 'text stream
UserName = ""
Do While Not TS.AtEndOfStream
Data = UCase(Trim(TS.readline))
UserName = Left(Data, InStr(Data, "<") - 1)
Loop
'
'****
' tidy up before we exit
'****
'
TS.Close
Set TS = Nothing
FSO.deletefile "c:\nbuser.txt"
Set FSO = Nothing
'
GetUserName = UserName
Exit Function
'
ErrorHandler:
GetUserName = "Error in GetUserName function"
End Function