Macro runs in Excel 2003, bombs in XP - Compatability question

H

Harry

Hello

Having an aggravating problem in a workbook. I didn't write it, it comes from a third party.

I download this workbook from the creator's site on my Excel XP (2000) machine, it runs fine. I make some changes and
save it. It works fine.

I download this workbook from the creator's site on my Excel 2003 machine, it runs fine. I make some changes and save
it. It works fine.

If I open the file saved with Excel XP on the 2003 machine, it runs fine.

If I open the file saved with Excel 2003 on the XP machine, it gives me an error as part of a VB script called module,
and I can't get it to run.

In other words, using the file from the XP machine, and doing work with that file on the 2003 machine, makes the file
impossible to move back to the Excel XP 2002 machine. The changes I made are minor, and not even a part of the VB code
that's showing up in the debugger with the error. The error code highlighted reads:

Compile error: Can't find project or library

When I press OK, it jumps to this part of the code:

Sub AddToListBox()
'this method is called when the workbook is first opened and when rows are added to the All
'Units worksheets. This method refreshes the Listbox on the Data worksheet with data from the
'All Units worksheet.
Dim iCounter As Integer
Dim sDataKey As String

Sheets("All Units").Select
Range("A1").Select
iCounter = 3


'find out how many rows in All Units worksheet contain data
Do Until (Trim(Range("$A" & iCounter).Value) & Trim(Range("$B" & iCounter).Value) & Trim(Range("$C" &
iCounter).Value) & Trim(Range("$D" & iCounter).Value) & Trim(Range("$E" & iCounter).Value)) = ""

The word Trim is highlighted in yellow, and it stops there. I've tested really carefully, moving the file I've saved
with Excel 2003 to 2 different machines with Excel 2002, and I get the same problem, yet no problem opening the same
file with Excel 2003.

Thank you
 
R

Rob van Gelder

When switching the workbook between versions, take a look at the references.
Suspect a reference is getting upgraded when moving to 2003 and causing the
break when moving back.

The symptom is simple functions like Left, Mid, Trim etc. result in compile
errors.

From VB | Tools | References
 
R

Rob van Gelder

References are Visual Basic links to other sources of compiled code.
eg. Reference to another workbook or OCX or DLL or TPL

You add References from the Visual Basic Editor - Tools menu, References
 

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