Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Old code still active

Status
Not open for further replies.

globalbear

IS-IT--Management
Joined
Dec 5, 2004
Messages
27
Location
SE
When I sometimes make changes to my VBA-code it doesn't seem to help - Excel still runs with my old code!

Example

Old code:
If Cells(6, 3) = "A" Then Cells(6, 3) = "A, Auto"

New code:
If Cells(6, 3) = "A" Then Cells(6, 3) = "A, Auto Reverse"

When I run this macro and cell C6 is set to "A" what does VBA do? Change it to "A, Auto Reverse" as it should? Nope, it changes the cell to "A, Auto". Aaaaaaaaaarghhhhhh!

It uses my old code that does not longer exist! What have I done wrong? Is there some stupid cache somewhere that I have to empty or is there a way to re-compile my code?

I have tried to restart Excel but that didn't help. I have had similiar problems a few times and sometimes it works with setting a remark ' in front of the line, run the code and then taking away the remark.

Is this some kind of general VBA-problem?

I'm running Excel 2003 SP1.

 


In over 10 years of VBA programming, I have NEVER had ghost code execute (code that was there but is not).

However, I have been confused by having old code in one procedure and new code in another and accidentally or unintentionally executed the wrong code.

BUT...

the old code was there!

Skip,

[glasses] [red]Be advised:[/red] Researchers have found another Descartes trueism, "Cogito ergo spud."
"I think; therefore, I YAM!
[tongue]
 
I've had similar experiences with VBA-Word.

Closing and restarting both the VBA editor and Word has solved the problem.
 
Seems like I'm alone with this problem...

When I run VBA in debug-mode (F8) I can see that VBA is actually skipping one line - now that's annoying! I can not force VBA to compile the code either.

It seems VBA cannot see that any changes to the code has been made and therfore does not compile the code before running it. I think the problem must be the process that checks if my code needs to be recompiled or not.

I spoke to my Co's Support Center yesterday and they suggested that it may be one or several .dll-files that are corrupted (the compilator would be in these .dll-files). I tried to repair my MS Office-installation but that didn't help. Next try would be to de-install MS-Office and then re-install it.

Another option could be that I have a couple of Excel add-ins installed with their own VBA-sections. One of them is Hyperion Essbase add-in. It may be that they could interfere with the compilation process somehow.

Anyway - it doesn't seem to be an easy problem to fix and since I am aware of it I can always find a work-around when it occurs.

But still - it's ****ing annoying!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top