PDA

View Full Version : VBA Coding window highlights text red and then deletes



usernamepass
11-27-2011, 10:29 AM
I am having a strange problem that I have never had before with VBA.

Whenever I try to type something in the main code window for anything (a Worksheet/Userform/Modules), as I type VBA keeps highlighting my code in red and if I stop typing VBA begins to delete what I just typed (usually one or two characters).

This is only happening for the workbook that I am currently working on, all the other ones are fine.

I just wanted to know if there was some setting that I accidentally hit that is causing VBA to do this.

I am using a lot of ActiveX controls which may be the issue.

Edit: I tried deleting everything of of my first worksheet code window and typed in a random three letters and hit space. It keeps popping up a window that says "invalid outside procedure." Windows keep popping up and I eventually just have to force quite (after 15-30 are on the screen and more are coming).

I also tried on another laptop and the same thing happened (with this workbook).

Kenneth Hobs
11-27-2011, 11:44 AM
Welcome to the forum!

Check in VBE: Tools > Options > Auto Syntax Check

I set all of those options. I don't see how it would delete characters.

Zack Barresse
11-27-2011, 11:44 AM
Hi, welcome to the board!

The deleting of characters issue, I wonder if you have a sticky keyboard perhaps?

The "invalid outside procedure" is generally when you have code outside of a standard sub routine. Check them and make sure this isn't happening. Can you post your code here?

usernamepass
11-27-2011, 12:10 PM
This is the workbook containing the code that is messing up VBA.

I know the code is extremely messy (I'm just beginning VBA, this is just a project for class). I also couldn't comment on the code since VBA liked to delete it.

At least this will let you see what I am talking about.

Zack Barresse
11-27-2011, 12:26 PM
What is the offending code? It runs fine for me.

usernamepass
11-27-2011, 01:31 PM
Turns out that the error happened when I had some items run when VBA started. I deleted them when I uploaded the file so nobody would have to deal with them to get to the code, that's why nobody saw the problems. I stopped the processes that ran in the beginning and now everything runs perfectly.

Thank You

Aflatoon
11-28-2011, 07:05 AM
Usually when such problems occur, you can simply press the Design Mode button to be able to work normally in the VB Editor.