Author Name and User Name - Does anyone know the VBA and cell formulas to use?

Tyron

Active Member
Joined
Dec 5, 2012
Messages
258
Hey Guys,

Probably something that isn't very hard. I have actually found out how to do the User Name.

VBA:
Code:
Username = Environ("UserName")
Cell Formula:
Code:
=Username()
This takes care of the Username.

I can't, for some reason, find anything online about grabbing the workbook's author(s) name though. Anyone out there know how to do this?

later

Ty
 

Some videos you may like

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

L. Howard

Well-known Member
Joined
Oct 16, 2012
Messages
4,514
Hi Tyron,

With the function in a standard module.
Use this on the worksheet

=LastAuthor()

Code:
Option Explicit

Public Function LastAuthor() As String
   Application.Volatile
   LastAuthor = ThisWorkbook.BuiltinDocumentProperties("Last Author")
End Function
Or with this sub in the sheet module and the above function in a standard module.
To list author in a cell by code.

Code:
Sub MisterAuthor()
 Range("C1").Formula = "=LastAuthor()"
End Sub
Regards,
Howard
 

Tyron

Active Member
Joined
Dec 5, 2012
Messages
258
Hey L. Howard,

Thanks for the reply. I will give it a try and let you know how it goes.

In your first example it seems to show that you have created a UDF and make a call to that UDF with the =LastAuthor(). Is this correct?

Also, would I be able to just type =builtindocoumentproperties.lastauthor("Last Author")
in a cell so I would not need any VBA?

I apologize if my previous post is confusing. I was actually looking for two different independent ways to find the information. 1.)using VBA so I can make it part of my macro 2.)Using Excel formula only so I can verify the information through a second source that isn't part of the macro.

Thanks again for your help.

Ty
 

L. Howard

Well-known Member
Joined
Oct 16, 2012
Messages
4,514
Hi Tyron,

Code:
In your first example it seems to show that you have created a UDF and make a call to that UDF with the =LastAuthor(). Is this correct?
Yes, that is true.


Code:
Also, would I be able to just type =builtindocoumentproperties.lastauthor("Last Author")
 in a cell so I would not need any VBA?

2.)Using Excel formula only so I can verify the information through a second source that isn't part of the macro.
Not that I know of. But may be possible.


Code:
1.)using VBA so I can make it part of my macro
The function I googled and posted does that, if I read you correct.

Put this in a standard module and type in two XX's in F1, then run Sub UseMyLastAuthor()


Code:
Option Explicit

Public Function LastAuthor() As String
   Application.Volatile
   LastAuthor = ThisWorkbook.BuiltinDocumentProperties("Last Author")
End Function

Sub UseMyLastAuthor()
If Range("F1") = "XX" Then

  MsgBox "There are two XX's in Cell F1 and they were put there by " _
         & vbCr & LastAuthor() & vbCr & "That is me."

End If
End Sub
Howard
 

Tyron

Active Member
Joined
Dec 5, 2012
Messages
258
Hey L. Howard,

Thanks for your help. I have discovered I think a problem though. It seems to be getting the name from somewhere other than the author. I guess I would need to know where it gets the name from within excel. I only say this because it runs normal, but for the name it is blank. This is strange.

I am unable to substantiate whether we can just directly put the information in to a cell formula as I cannot get the UDF to work. Probably not the UDF's fault. I just need to find out where in the computer I can go to visually confirm and/or change the "Authors" name so that it can work.

Let me know if you figure it. I am off to hunt this bugger down.

later

Ty
 

Watch MrExcel Video

Forum statistics

Threads
1,102,302
Messages
5,486,058
Members
407,529
Latest member
netojose

This Week's Hot Topics

Top