How Do You Use Visual Basic With Excel?
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. Press Alt + F11 to open the Visual Basic editor from Excel. Click “Insert > Module” to open a blank module window. Copy and paste the following code into the blank window: Sub BoldRed() With Selection.Font .ColorIndex = 3 .Bold = True End Sub 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.