How to Use Visual Basic With Excelby Stephanie Ellen
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.
- check The macros you create are named the same thing as the "sub" by default. In the example code, the macro will be called "BoldRed," but you can change the macro name to whatever you want.
- photo_camera computer image by Ewe Degiampietro from Fotolia.com