Excel Visual Basic Variables, Part 1: Variable Types
Subscribe to continue reading
Subscribe to get access to the rest of this post and other subscriber-only content.
Subscribe to get access to the rest of this post and other subscriber-only content.
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,…
1. The Application Keyword Use “Application” to refer to Excel, e.g.: Application.ActivePrinter Name of the Active Printer.Application.Name Name of the program running (“Microsoft Excel”).Application.Path The path from which the program is running. 2. ActiveControl Instead of the name of a specific control (e.g. txtEdit), you can use the keyword ActiveControl. This will let your program refer…
This is an excerpt from Microsoft Excel Visual Basic Help, with extra Notes. The syntax in a Visual Basic Help topic for a method, statement, or function shows all the elements needed to use the method, statement, or function. The examples in this topic explain how to interpret the most common syntax elements. 1. Activate…
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…
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….
1. What are Objects and Collections? Visual Basic defines a number of what it calls Objects. Examples of Objects are: In object-orientated terminology, Objects belong to Classes. Collections are groups of Objects. Here are some examples of Collections that Visual Basic defines: 2. The Excel Object Model Excel, too, has objects of its own. When…