in the workbook.open event
private sub workbook_open()
dim userFound as long
on error GOTO errhandler
user found = thisworkbook.worksheets("sheet1").range("$B:$B").find(what:=environ("username"), LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False).row
exit sub
errhandler:
msgbox("User not authorised. Workbook will close")
thisworkbook.saved = true
thisworkbook.close
end sub
this will return the row number it finds the match in to the variable, if no match is found the error causes it to jump to the exit.
Sent from my HTC One_M8 using Tapatalk
Bookmarks