Hi All,
I want to run an event for specific user. In this case, only John Doe should be able to run this command. It works fine if i put john doe in there and i get the MSGBOX since my windows log in is not John doe. But when I put my windows login there (and only I can run it), i dont get any msgbox or the rest of the command does not run....anyone can help me what I am missing? code in question is in red
Thanks all
![]()
Private Sub CommandButton5_Click() If LCase(Environ("username")) <> "john.doe" Then MsgBox "you dont have permission" Cancel = True Exit Sub ActiveWorkbook.Saved = True 'variables Dim fso As Object Dim fromdir As String Dim todir As String Dim fnames As String MsgProceed = MsgBox("Move and Archive Tracker?", vbYesNo) If MsgProceed = vbNo Then Exit Sub 'source and destination fromdir = "\\tarcds01\eCTD_Submission\TRACKERS\" & ActiveSheet.Range("P1").Value & "\" & ActiveSheet.Range("Q1").Value & "\" & ActiveSheet.Range("P1").Value & "-" & ActiveSheet.Range("Q1").Value & "-" & ActiveSheet.Range("R1").Value & "-" & ActiveSheet.Range("S1").Value todir = "\\tarcds01\eCTD_Submission\TRACKERS\Archive-Backup\BACKUP\" 'file types FExtension = "*.xlsm" fnames = Dir(fromdir & FExtension) Set fso = CreateObject("Scripting.FileSystemObject") fso.MoveFile Source:=fromdir & FExtension, Destination:=todir End Sub
Bookmarks