"Strict" VB compiler

  • Thread starter Thread starter Eivind
  • Start date Start date
E

Eivind

I have written some VB code as an addin for Excel 2003, which works fine on
my computer. When transferring the code to a colleague, I get all sorts of
error messages, even if he also uses Excel 2003. It seems that the VB
compiler on my colleagues computer insists that all variables has to be
declared. Furthermore, on his computer references as cells(i,j).value gives a
type mismatch diagnostic when the cell is empty. And
Application.WorksheetFunction.Sum(range) gives an error if some of the cells
in range are empty. What can be the explanation for these differences? Any
suggestions? Thanks!
 
This is an Outlook group, you will get better Excel answers if you post to
an Excel group.
 
Your colleague's Option in VBA (VB) are set to Explicit - yours are not. You
may have a missing variable or a variable that is not defined i.e. Dim mVar
where on your colleague's machine Excel expects something like Dim mVar as
(String, Integer, Double - one of the definition types).

It is safer and better to have the Option Explicit set, so I might suggest
you do so on your machine, recompile the code and then when you port it to
another machine it will work.

Sol.
 
Back
Top