You declare all your variables as ByRef. EmpNum and CompNum should be ByVal - since you can't change them.