How to Use Visual Basic With Excel

By Stephanie Ellen

VBA can replace dull tasks with automation.
i computer image by Ewe Degiampietro from <a href=''></a>

If you are tired of formatting worksheets the same way over and over again, or entering the same formulas repetitively, Excel's Visual Basic for Applications (VBA) was made for you. The programming language, a subset of Visual Basic, can replace those dull tasks with an automated function. The language doesn't even require an additional cost outlay---you may not have noticed it, but the Excel Visual Basic Editor is included with every copy of Excel.

Step 1

Press Alt + F11 to open the Visual Basic editor from Excel.

Step 2

Click "Insert > Module" to open a blank module window.

Step 3

Copy and paste the following code into the blank window: Sub BoldRed() With Selection.Font .ColorIndex = 3 .Bold = True End Sub

Step 4

Press F5 to run your macro. When you see a macro dialog box, enter the shortcut key you want to access the macro with, then click "Run." Whatever text you have selected will automatically become bold and red. You can use the shortcut key you specified to execute the macro any time you want.