SNB,
I'm having trouble implementing your code. I'm getting a Compile Error at this line
Sheet2.Columns(1).Find(Environ("username")).Offset(, 1) = Format(Date, "dd-mm-yyyy")
If Err.Number > 0 Then Sheet2.Cells(.Rows.Count, 1).End(xlUp).Offset(1).Resize(, 2) = Split(Environ("username") & "|" & Format(Date, "dd-mm-yyyy"), "|")
It's highlighting the "(.Rows." piece. Here's the full macro I tried to make using your code:
Option Explicit
Private Sub Workbook_Open()
Dim User As String
On Error Resume Next
' check to see if the file was opened in readonly mode, if so exit sub
If Me.ReadOnly = True Then Exit Sub
Application.ScreenUpdating = False
Sheet1.Select
' can write and save changes - not read only
Sheet2.Columns(1).Find(Environ("username")).Offset(, 1) = Format(Date, "dd-mm-yyyy")
If Err.Number > 0 Then Sheet2.Cells(.Rows.Count, 1).End(xlUp).Offset(1).Resize(, 2) = Split(Environ("username") & "|" & Format(Date, "dd-mm-yyyy"), "|")
Select Case .Cells(Rows.Count, 1).End(xlUp).Text
Case "LUPOREJ"
User = "John"
'Case "IDUNNO"
'User = "Somebody else"
Case Else
User = "I don't know who you are."
End Select
Me.Save 'save now to capture username in log
Sheet1.Select
CreateObject("WScript.Shell").Popup " Hello " & User & ", this is a first attempt at a messaging system within Excel for specific worksheets." & vbCrLf & "This message will self-destruct after 10 seconds, which should be enough time to read this message." & vbCrLf & " If I've done it right you should not see this msgbox again. Thanks for trying it.", 10, "This Msgbox will close itself."
Application.ScreenUpdating = True
End Sub
Also, anybody; the UserName may come in in all caps, or all lowercase, or a mixture. How do I configure my Select Case to recognize the UserName regardless of the case?
Bookmarks