You will notice that most of the options in VB Editor have keyboard shortcuts mentioned next to it. You can explore the available options by clicking on each of the menu element. It is similar to the Excel ribbon where you have tabs and options with each tab. This is where you have all the options that you can use in the VB Editor. Now let’s quickly go through each of these components and understand what it does: Menu Bar These are then described in detail in the below sections of this tutorial.
And most of the time, you’ll not be required to use all the options, only a hand full.īelow is an image of the different components of the VB Editor. But as you get used to working with VBA, you would get comfortable with most of these. Note: When I started using VBA years ago, I was quite overwhelmed with all these new options and windows. In this section, I will take you through the different parts of the Visual Basic Editor application. While Excel has improved tremendously in design and usability over the years, the VB Editor has not seen any change in the way it looks. There are different options and sections that may seem completely new at first.Īlso, it still has an old Excel 97 days look. When you open the VB Editor for the first time, it may look a bit overwhelming. Anatomy of the Visual Basic Editor in Excel This is usually the case with worksheet events.
This is useful when you want to write code that works only for a specific worksheet.
This method wouldn’t just open the VB Editor, it will also take you to the code window for that worksheet object. Go to any of the worksheet tabs, right-click, and select ‘View Code’. This is a less used method to open the Vb Editor.
The shortcut for the Mac version is Opt + F11 or Fn + Opt + F11 Using the Developer Tab This shortcut works as a toggle, so when you use it again, it will take you back to the Excel application (without closing the VB Editor). The easiest way to open the Visual Basic editor is to use the keyboard shortcut – ALT + F11 (hold the ALT key and press the F11 key).Īs soon as you do this, it will open a separate window for the Visual Basic editor. Keyboard Shortcut to Open the Visual Basic Editor
We want to update the comment value in column C based on the grade in column B. In the second video example, we have a list of students in column A and their corresponding grade in column B. If we entered "S" in cell A2, we want "South" to appear in cell C2, and so on. So if we entered "N" in cell A2, we want "North" to appear in cell C2. In the first video example, we are going to use the IF-THEN-ELSE statement to update cell C2 with "North", "South", "East" or "West" depending on the region code entered in cell A2.
If LRegion ="N" Thenįinally, let's look at an example that uses Else. Next, let's look at an example that uses ElseIf. Let's look at some Excel IF-THEN-ELSE statement function examples and explore how to use the IF-THEN-ELSE statement in Excel VBA code:įirst, let's look at a simple example. The IF-THEN-ELSE statement can only be used in VBA code in Microsoft Excel.