I'm using VBA to display a welcome message with the username. Additionally I want to keep track of the username (taken from environment variables), date and time in one of the sheets.
For example: If I open the Excel file, it has to be tracked like following in one of the sheet
skiran 11/13/2014 2:00 AM
My code so far
Private Sub Workbook_Open1()
Dim sName As String
Dim sTxt As String
Dim CurrTime As Long
sName = Environ("UserName")
CurrTime = Hour(Now)
Select Case CurrTime
Case Is > 18
sTxt = "Good evening, "
Case Is > 12
sTxt = "Good afternoon, "
Case Is < 6
sTxt = "Good morning, "
End Select
msgbox sTxt & sName
End Sub