This Excel tutorial explains how to open the Visual Basic Editor in Excel 2016 (with screenshots and step-by-step instructions).
See solution in other versions of Excel:
Hey guys, I'm using Excel 2016 for Mac. When I open Visual Basic Editor and start typing out some stuff, the text types straight downward, as though I'm hitting the enter key after each character.
How to open the VBA environment
You can access the VBA environment in Excel 2016 by opening the Microsoft Visual Basic for Applications window.
First, be sure that the Developer tab is visible in the toolbar in Excel.
Free Visual Basic Editor Download
The Developer tab is the toolbar that has the buttons to open the VBA editor and create Form/ActiveX Controls like buttons, checkboxes, etc.
To display the Developer tab, click on File in the menu bar and select Options from the drop down menu.
When the Excel Options window appears, click on the Customize Ribbon option on the left. Click on the Developer checkbox under the list of Main Tabs on the right. Then click on the OK button.
Select the Developer tab from the toolbar at the top of the screen. Then click on the Visual Basic option in the Code group.
Now the Microsoft Visual Basic for Applications editor should appear and you can view your VBA code.
This is a short step-by-step tutorial for beginners showing how to add VBA code (Visual Basic for Applications code) to your Excel workbook and run this macro to solve your spreadsheet tasks.
Most people like me and you are not real Microsoft Office gurus. So, we may not know all specificities of calling this or that option, and we cannot tell the difference between VBA execution speed in Excel 2010, 2013 and 2016. We use Excel as a tool for processing our applied data.
Visual Basic Download
Suppose you need to change your data in some way. You googled a lot and found a VBA macro that solves your task. However, your knowledge of VBA leaves much to be desired. Feel free to study this step-by-step guide to be able to use the code you found:
Insert VBA code to Excel Workbook
For this example, we are going to use a VBA macro to remove line breaks from the current worksheet.
- Open your workbook in Excel.
- Press Alt + F11 to open Visual Basic Editor (VBE).
- Right-click on your workbook name in the 'Project-VBAProject' pane (at the top left corner of the editor window) and select Insert -> Module from the context menu.
- Copy the VBA code (from a web-page etc.) and paste it to the right pane of the VBA editor ('Module1' window).Tip:How to speed up macro execution.
If the code of your VBA macro does not contain the following lines in the beginning:
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual - Then add the following lines to get your macro to work faster (see the screenshots above):
- To the very beginning of the code, after all code lines that start with Dim (if there are no 'Dim' lines, then add them right after the Sub line):
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual - To the very of the code, before End Sub:
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
These lines, as their names suggest, turn off screen refresh and recalculating the workbook's formulas before running the macro.
After the code is executed, everything is turned back on. As a result, the performance is increased from 10% to 500% (aha, the macro works 5 times faster if it continuously manipulates the cells' contents).
Save your workbook as 'Excel macro-enabled workbook'. Press Crl + S, then click the 'No' button in the 'The following features cannot be saved in macro-free workbook' warning dialog.
The 'Save as' dialog will open. Choose 'Excel macro-enabled workbook' from the 'Save as type' drop-down list and click the Save button.
Press Alt + Q to close the Editor window and switch back to your workbook.
- To the very beginning of the code, after all code lines that start with Dim (if there are no 'Dim' lines, then add them right after the Sub line):
How To Open Visual Basic Editor In Excel Mac
How to run VBA macros in Excel
When you want to run the VBA code that you added as described in the section above: press Alt+F8 to open the 'Macro' dialog.
Then select the wanted macro from the 'Macro Name' list and click the 'Run' button.