What Are VB Projects, Objects, Forms, Modules and Procedures?
In the Excel Visual Basic Editor (Alt+F11), display the Project Explorer (Ctrl+R). Usually (and in this picture), it appears at the top left, under the toolbars: In Project Explorer, you will see a VBAProject for every Excel file that is open. The list will include the hidden Personal Macro workbook, Personal.xlsb, if you have personal macros….
How to Get Help in the Excel Visual Basic Editor
At this point, you might be wondering, “What if I get stuck?” Fear not, help is at hand! Microsoft offers extensive online documentation of the VB language. To be fair and warn you, it’s often not that useful. You might find more assistance if you Google for your topic. There is a lot of programming…
How to Debug Code in the Excel Visual Basic Editor
In an earlier post, we recorded two Excel macros in Visual Basic, and ran them. Then, in the next post, we viewed the code in the Excel Visual Basic Editor. Code you have recorded will usually run. However, you may want to change it for all sorts of reasons. To tidy it up, make it…
Details of The Excel Visual Basic Editor
The Excel Visual Basic Editor can be set to appear in a variety of ways. In the appearance shown below (the default) the majority of windows appear docked at one edge of the screen. Code windows can be tiled together on the screen, or one can be maximized. The main features of the screen are…
Meet the Excel Visual Basic Macro Editor
The macros you recorded in the previous post are stored in an Excel file. To edit it you use what looks like a separate program, the Visual Basic Editor. Open it with the Developer ribbon (Code group) > Visual Basic Editor (Alt+F11). You will find newly-recorded macros under Modules in the explorer on the left…
Exercise: Record and Run Simple Excel Macros
In our previous post, we looked at the steps to record and run a macro. Practice makes perfect, or at least helps us improve, so let’s do an exercise. We will record a simple macro to format the current cell in bold, italics, and single-underscored. Then it will move one cell to the right, ready…
How to Record a Macro in Excel (or Microsoft Word)
The easiest way to create a macro is: The instructions below are for Excel. Word is similar, but has its own quirks (and no “Absolute or Relative”). If you want to look at programming basics first, see this previous post. 1. Recording a Macro Absolute or Relative What does that mean? When you record Absolute,…
Start Programming Excel: An Introduction to Macros
A Macro is a computer program that can duplicate actions you take in a spreadsheet. Macros perform key tasks faster. They can have a short-cut key combination to run them easily. Creating Excel and Word Macros is easier than most other methods of programming. You simply record the actions you took in the program. You…
FORMULATEXT to Display the Formula in a Cell
Here is a function that displays the formula in another cell: FORMULATEXT(reference). The argument, “reference”, is the cell address that contains the formula you want to display. This is most useful for documentation purposes. For example, when you want to print out a spreadsheet with its formulas. If you have spent much time on this…
Should I use a VBA Macro Function or Call a Worksheet Function?
If the function you want to use exists in Excel VBA, use that. It will be faster and cleaner, and work in all Microsoft Office programs, not only in Excel. Here is a full list of Excel VBA Functions. If the function you want is not there, but exists in the Worksheet, you may be…
How to Use a Worksheet Function in a Macro: Proper Case Names
In some cases, VBA does not have a specific function, but the Excel Worksheet does. This Excel Visual Basic (VBA) code example demonstrates: How to call that Worksheet Function from a Macro. In this particular example, how to call the Worksheet Function =PROPER() from VBA. The function to downcase parts of surnames that normally appear…