For clarity, and to promote good coding practice, one should always declare variables before their use.
Looking at your function, there is no way to tell a) if the variables are simply undeclared, or b) are global variables declared outside the function.
You could use "Case...End Case" instead of the multiple "If...End If" statements: