I'd read your question slightly differently to Andrew, so here's my two pennyworth in addition to Andrew's eloquent description of late binding.
Convention is to declare your variables at the top of the routine since VBA variables are scoped for the routine they run in. This actually makes little sense until you compare it to other languages, for example:
VB.NET
VBA
So whereas VB.Net has block level scope - t is only available in the If block, VBA does not, t is available throughout the routine.
In VBA, it's therefore really a matter of preference. Keeping the variable declaration near the code that uses it makes sense from a refactoring viewpoint - it makes it easier to transfer the whole bit to another sub routine. Just bear in mind it can't be used before it's declared - so usually the preference is to declare at the top so it's usable throughout.
In addition to Andrew's point, the only time declaring at the top may slow your code down is when you auto instance in your declaration, so:
As opposed to:
The reason for that is the class is created earlier - it's generally not good practice anyway since you can't check whether the class is nothing (which is often useful)
Bookmarks