Variable declaration in Excel 2007

Q

Q

Hello

I have a macro from Excel 2003, and it works fine in Excel 2003. The macro
processes some data and saves the output Excel file to a folder. In the
macro, I have a variable that stores the output path. The macro uses the
value in the output path variable to save the Excel file.

For some reason, when running this macro in Excel 2007, the output path
variable is blank! The variable declaration is in the middle of the
subroutine in the macro and the variable assignment to the output path is
done right afterward.

I did a search on the project, thinking perhaps elsewhere in the code that
causes the output path to be blank, but nowhere else uses this variable but
this subroutine.

Later, when I moved this variable declaration and assignment to near the
beginning of the subroutine, it works fine.

The location of variable declaration in Excel 2007 matters?

Thanks,

Q
 
B

Barb Reinhardt

Just curious. Do you have Option Explicit at the beginning of your modules
and have you declared all variables?

HTH,
Barb Reinhardt
 
Q

Q

Barb:

Yes and yes.

Q

Barb Reinhardt said:
Just curious. Do you have Option Explicit at the beginning of your modules
and have you declared all variables?

HTH,
Barb Reinhardt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top