I'm on a roll now...
How do I get cells to populate with the following on save?
Date
Time
Login name
This is probably easier to do than the last one!
I'm on a roll now...
How do I get cells to populate with the following on save?
Date
Time
Login name
This is probably easier to do than the last one!
Private Sub Workbook_BeforeClose(Cancel As Boolean)
[a1].Value = Now
[a2].Value = Environ("NWUSERNAME")
End Sub
Change a1 & b1 to whichever cells you want the info in.
Col
Date : =Date
Time: = Date mod 1
Login name: = Environ("username")
HTH
--
AP
"EJ" <EJ@discussions.microsoft.com> a écrit dans le message de news:
9260D3C5-9362-4F64-B029-9BE7317361ED@microsoft.com...
> I'm on a roll now...
>
> How do I get cells to populate with the following on save?
>
> Date
> Time
> Login name
>
> This is probably easier to do than the last one!
>
>
try the below
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Worksheets("SHEET5").Cells(2, 3) = Int(Now()) ' DATE TO C2
Worksheets("SHEET5").Cells(4, 3) = Now() - Int(Now()) ' Time to C3
Worksheets("SHEET5").Cells(5, 3) = Environ$("Username") ' Windows username
to C4
End Sub
Change sheet name and cell refs
--
Tony Green
"EJ" wrote:
> I'm on a roll now...
>
> How do I get cells to populate with the following on save?
>
> Date
> Time
> Login name
>
> This is probably easier to do than the last one!
>
>
Environ("NWUSERNAME")
returns nothing for me - is that what you really intended?
--
Regards,
Tom Ogilvy
"colofnature" wrote:
>
> Private Sub Workbook_BeforeClose(Cancel As Boolean)
>
> [a1].Value = Now
> [a2].Value = Environ("NWUSERNAME")
>
> End Sub
>
>
> Change a1 & b1 to whichever cells you want the info in.
> Col
>
>
> --
> colofnature
> ------------------------------------------------------------------------
> colofnature's Profile: http://www.excelforum.com/member.php...o&userid=34356
> View this thread: http://www.excelforum.com/showthread...hreadid=544777
>
>
Works for me - returns the ID I logged into the network with. "Environ("USERNAME")" also works.
Not for me.
Windows XP
and I have never seen it offered as a general solution. Username seems
much more robust. Are you on a Novell network. A google search seemed to
associate it with a Novell Network.
--
Regards,
Tom Ogilvy
"colofnature" wrote:
>
> Works for me - returns the ID I logged into the network with.
> "Environ("USERNAME")" also works.
>
>
> --
> colofnature
> ------------------------------------------------------------------------
> colofnature's Profile: http://www.excelforum.com/member.php...o&userid=34356
> View this thread: http://www.excelforum.com/showthread...hreadid=544777
>
>
Yup, you're right, the office network is Novell. I just iterated the environ(x) variables and picked the first one that returned a user id...![]()
Col
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks