I'm trying to create a worksheet that when filled out, will compared a cell labeled "Managers Signature" to the current logged in user Environ("UserName"). I'm using the following code:
Private Sub Worksheet_signature() Dim UserName As String 'the name of the current user UserName = LCase(Environ(UserName)) 'on opening, find out who this is and convert to lower case If LCase(Cells(34, 4).Value) <> UserName Then 'compare username to username in signiture field MsgBox ("Manager Signature does not match the user filling out this form.") 'Display error message box End If End Sub
I'm new to VBA in excel, so I'm probably missing something simple. I'm use to C++, so trying to learn VBA code. File is saved as an xlsm file.