Logging username, date and time
Hi Bob,
This is Sriram and i utilized your code below by which you helped Maddoktor.
But when I'm on this macro excel file, if some other excel file (any excel
file) is also opened and want to verify some data by going to that file,
immediately the sheets which has been opened for the particular User is
getting closed and when I come back again to this file those sheets are not
getting visible again. I don't know what's wrong in this.
I request you to kindly clear this and help me out, because I'm doing a
project for my colleagues in my office by making the file available in the
local server.
Kindly resolve this issue at the earliest.
Regards,
Sriram
"Bob Phillips" wrote:
'-----------------------------------------------------------------
Private Sub Workbook_Open()
'-----------------------------------------------------------------
Dim sUser As String
sUser = Environ("UserName")
Select Case sUser
Case "AB":
With Worksheets("Finance")
.Visible = xlSheetVisible
Worksheets("Marketing").Visible = False
Worksheets("Design").Visible = False
.Activate
End With
Case "MN":
With Worksheets("Marketing")
.Visible = xlSheetVisible
Worksheets("Finance").Visible = False
Worksheets("Design").Visible = False
.Activate
End With
Case "XY":
With Worksheets("Design")
.Visible = xlSheetVisible
Worksheets("Finance").Visible = False
Worksheets("Marketing").Visible = False
.Activate
End With
End Select
End Sub
'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code
--
HTH
Bob Phillips
(remove xxx from email address if mailing direct)
"Maddoktor" wrote in message
...
Thanx Bob ... worked perfectly.
Maybe you could help me to expand it even further and I am not sure if I
should start another thread.
My workbook has 5 worksheets. The first three worksheets are designed as
individual menus/links to other worksheets that are hidden. i.e. one
worksheet is the menu options for finance, one for marketing, one for
design. I would like for one of the three individual menus (worksheets)
to be displayed depending on the username of whom opens the workbook.
i.e. if user AB opens the workbook, then the finance menu (worksheet) is
displayed that has links to the finance worksheets (that were hidden)
and then for these hidden worksheets to be displayed.
Is this at all possible?
Maddoktor
Bob Phillips wrote:
'-----------------------------------------------------------------
Private Sub Workbook_Open()
'-----------------------------------------------------------------
Dim iRow As Long
Const SH_NAME As String = "Hidden"
With Worksheets(SH_NAME)
iRow = .Cells(.Rows.Count, "A").End(xlUp).Row
If iRow < 1 Or .Range("A1") < "" Then
iRow = iRow + 1
End If
.Cells(iRow, "A").Value = Environ("UserName")
.Cells(iRow, "B").Value =Format(Date, "dd/mm/yy")
.Cells(iRow, "C").Value = Format(Time, "hh:mmAM/PM")
End With
End Sub
'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code
|