PC user tag with date/time stamp

TobyCobbin

New Member
Joined
Feb 6, 2014
Messages
7
I've got a "submit" button on my Excel spreadsheet and I would like to know what script/command to add to the assigned macro so that when the form is received by a second user (authoriser) it has the name and date/time tag of the person who submitted the form (form completer).

Is there anyway of looking at the user who is logged into the pc and "capturing" that information?

So once the form has been submitted, in the cell next to the submit button I need it to show something like: MR USER1 08/02/2014 10:08

Similarly, I'll need to do the same on a second submit button so the end view looks like:

MR USER1 08/02/2014 10:08
MRS USER2 09/02/2014 15:37

Any help/comments would be greatly received.
 
Ok, so to get the date/time stamp I have entered:

Sub ShowTime()
Range("D10") = Now()
End Sub

What command do I need to enter to get the username details? I have looked on the (Environment variables) link and can see %USERNAME% which will return "the user name corresponding to the current account" but i'm not sure how to type it out!

Or is there another way to return the user name?

Toby
 
Upvote 0
Hi Toby,

That link gave you the names but the % in the usage was for windows scripting. Just use:

Code:
environ("USERNAME")

Teeroy.
 
Upvote 0
Thanks Teeroy - what is the exact script to put the username into cell D9? And how does it go with the time/date script? Can you write it out for me please?
 
Upvote 0
Try the following inside your sub:

Code:
Range("D9").value = environ("USERNAME")
Range("D11").value = environ("USERNAME") & " " & Now()
 
Upvote 0

Forum statistics

Threads
1,226,866
Messages
6,193,421
Members
453,798
Latest member
jasonsd

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