Hi RBS:
IsEmpty(MyVar) will return a False if the variable has been initialized.
For Example:
Sub Test1()
Dim s As String
MsgBox IsEmpty(s)
End Sub
Sub Test2()
MsgBox IsEmpty(s)
End Sub
Hope this helps!
Regards,
Vasant
"RB Smissaert" <bartsmissaert@blueyonder.co.uk> wrote in message
news:%235irmsoTFHA.3620@TK2MSFTNGP09.phx.gbl...
> Peter, Dave,
>
> That is it!
>
> I had Option Explicit at the top of the module that got the code imported.
> If I leave this off the code will run happily even with un-declared
> variables.
> I will now have to figure out what happens when there are these
un-declared
> variables.
> It causes some strange behaviour or maybe not:
>
> If VarNonse = False Then
> Columns(2).Delete
> End If
>
> This will delete the column, even when the variable is declared nowhere.
> I suppose this is expected in that un-declared equates to false.
> In fact this probably is more trouble than getting the compile error as I
> now don't know
> if the variable was un-declared or declared but False.
>
> Is it possible to check somehow if a variable was declared or not?
>
> Thanks again for all the contributions; I learned something there!
>
>
> RBS
>
>
> "RB Smissaert" <bartsmissaert@blueyonder.co.uk> wrote in message
> news:OlThA0$SFHA.2872@TK2MSFTNGP14.phx.gbl...
> > Have the following situation:
> > An .xla file will import a Sub from a text file and then run it like
this:
> >
> > Dim strSub as String
> >
> > 'some code here to get the Sub imported
> > Application.Run strSub
> >
> > Now it is possible that in this imported Sub are variables that are not
> > defined publicly, so there
> > will be a compile error, variable not defined.
> > As this is not a runtime error I am not sure this error can be handled
> > gracefully, but I would be interested
> > in any suggestions how this could be done.
> >
> >
> > RBS
> >
>
Bookmarks