Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

How to use variables without declaring in userform

  Asked By: Madeleine    Date: Oct 20    Category: MS Office    Views: 728
  

Is there any option to use variables in userform with out declaring
them?

In my macro i have used several variables with out declaring them,
later on i have to use userform for my macro and pasted the whole code
in userform, when i run the macro in Excel 97 i encountered errors for
not declaring the variables.

but code works fine in excel2007.

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Zack Thompson     Answered On: Oct 20

You probably have Option Explicit at the top of your userform  module,
which demands variable declaration.

You should ALWAYS have Option Explicit in all modules, it is a bad idea
to rely on implicit variable declaration.

 
Answer #2    Answered By: Krista Warren     Answered On: Oct 20

It's difficult to see what you are doing, and especially why it would work
in 2007, but not in 97. There might be a different incompatibility.

Essentially, you should not expect a spreadsheet (particularly a macro  in a
spreadsheet) to be able to work with two versions of Excel so far apart.

You should not be looking at ways to use variables  without declaring  them
somewhere. They really should be declared, and then the compiler can assist
you in finding programming errors.

However, you should only declare variables in one place. If they need
global scope, make them public.

 
Didn't find what you were looking for? Find more on How to use variables without declaring in userform Or get search suggestion and latest updates.




Tagged: