Did you know that you can change font colors in VBA editor. We can find various text types inside the VBA editor. These different text types have different font colors in default. Here is the complete list of text types you can find inside the VBA editor.
- Normal Text
- Selection Text
- Syntax Error Text
- Execution Point Text
- Breakpoint Text
- Comment Text
- Keyword Text
- Identifier Text
- Bookmark Text
- Call Return Text
In default, these various text types have different colors. However we have an option to choose colors for these text types according to our preference. So today I'm going to show you how to change font colors in VBA editor. First, launch your Excel application and create blank workbook. Then go to the VBA editor. You can click inside the spreadsheet and press Alt + F11 to use shortcut keys to open the VBA editor.
So this is a sample code I have written in a module.
As you can see, I'm using default text colors in VBA editor. Now let's see how to change the text colors inside the editor. Click on "Tools" menu and select "Options".
Then "Options dialog box" will open like this.
This dialog box has 4 tabs.
- Editor
- Editor Format
- General
- Docking
Editor tab is selected default. Now select the "Editor Format" tab.
As you can see different text types are listed under code colors. When you select a text type, font color of that text type is shown under the Foreground. In default, Normal text foreground color is set to Auto. If you select "Syntax Error Text" then Foreground will change to red like this.
Also sample text will be shown in the bottom right corner of the dialog box. So you can easily preview the formatting of the text when you do the changes.
Now let's change color of the "Normal Text". First select the "Normal Text" under code colors and then select color you want from the Foreground dropdown.
However as you can see there are limited number of colors we can choose for the font colors. So I selected different color for the "Normal text" and this is how my code looks like now.
In default, both "Normal Text" and "Identifier Text" have same font color. So if I change the "Identifier Text" to the same color as "Normal Text" then sample code will look like this.