VBA & macros
Automate repeat work with macros and VBA code.
- VBA For Next Loop: Syntax, Examples, and Common ErrorsA VBA For...Next loop repeats a block of code for a counter that moves through a specified range. In Excel, it is…
- VBA For Loop Negative: How Step -1 WorksYes. A VBA For loop can count downward by using a negative Step, such as For i = 10 To 1 Step…
- VBA For Loop Backwards: Syntax, Examples, and Common FixesTo make a VBA For loop count backwards, give it a negative Step, such as For i = 10 To 1 Step…
- VBA For Each Loop: Syntax, Examples, and Common ErrorsA VBA For Each loop repeats an action for every item in a collection or array, without requiring you to manage an…
- VBA Double Quotes in Strings: How to Escape a QuoteTo include a double quote inside a VBA string, type two double quotes in a row: VBA treats "" inside a string…
- VBA Double Loop: How Nested For Loops Work in ExcelA VBA double loop is a loop inside another loop: the outer loop runs once, and for each pass the inner loop…
- VBA Display UserForm: Methods, Examples, and FixesIn Excel VBA, display a UserForm by calling its Show method, such as frmEntry.Show. By default, the form is modal; add vbModeless…
- VBA Dictionary With Multiple Values: Practical MethodsYes. A VBA Scripting.Dictionary can hold multiple values for one key, but each key still maps to a single item: make that…
- VBA Display Array in MsgBox: Safe, Clear ExamplesVBA cannot display an array directly in a MsgBox: first convert its elements to a text string. For a one-dimensional array, use…
- VBA Dictionary Split: Turn Text into Keys and ValuesIn VBA, use the Split function to break a string into an array, then add the pieces to a Scripting.Dictionary when you…
- VBA Dictionary SumIf: How to Group and Sum Data in ExcelTo perform a SUMIF-style total in VBA, use a Scripting.Dictionary: make each category a key and add each matching amount to that…
- VBA Dictionary Set: Create, Add, and Retrieve ItemsIn VBA, use Set to assign a Dictionary object to an object variable, for example Set dict = CreateObject("Scripting.Dictionary"). Add ordinary data…
- VBA Dictionary Remove Key: Safe Removal and Common ErrorsTo remove one entry from a VBA Dictionary, call its Remove method with the key: dict.Remove key. If the key might be…
- VBA Dictionary Reference: Setup, Binding, and AlternativesIn Excel VBA, a Dictionary is provided by the Microsoft Scripting Runtime. To use it with early binding, enable the Microsoft Scripting…
- VBA Dictionary Object: How It Works and When to Use ItA VBA Dictionary object stores unique keys alongside associated values, letting a macro retrieve, update, and count information by key. In Excel…
- VBA Dictionary: How to Read Key-Value Pairs in ExcelIn VBA, read a Scripting.Dictionary pair by using its key to retrieve the value, as in dict(key), or loop through dict.Keys and…
- VBA Dictionary Multiple Items per Key: Practical GuideYes. A VBA Scripting.Dictionary can hold multiple items for one key if you store a container—most often a Collection—as that key’s value,…
- VBA Dictionary Library: Setup, Uses, and AlternativesA VBA dictionary library is a way to store and retrieve data as key–value pairs, with each key identifying one item. On…
- VBA Dictionary Keys: How They Work and How to Use ThemIn VBA, a dictionary key is a unique identifier used to store and retrieve an associated value in a Scripting.Dictionary. Each key…
- VBA Dictionary Length: How to Count ItemsIn VBA, use a Dictionary’s Count property to find how many key-value pairs it contains: for example, Debug.Print dict.Count. A Dictionary has…
- VBA Dictionary Item Count: Use the Count PropertyTo get the number of entries in a VBA Scripting.Dictionary, read its Count property: dict.Count. It returns the number of key-item pairs…
- VBA Dictionary Item: Get, Set, Check, and Loop ThroughA VBA Dictionary Item is the value associated with a key in a Dictionary object. In Excel for Microsoft 365 on Windows,…
- VBA Dictionary Index: Access Items by PositionA VBA Scripting.Dictionary has no built-in numeric index for its entries: you retrieve an item by its unique key. To get an…
- VBA Dictionary Get Value by Key: Syntax and ExamplesTo get a value from a VBA Scripting.Dictionary, use its key as the item index: value = dict.Item(key) or the shorter value…
- VBA Dictionary Functions and How to Use ThemIn VBA, a Dictionary is an object for storing unique keys alongside values, and its main functions are the Add, Exists, Item,…
- VBA Dictionary For Each Key: How to Loop Through ItemsTo loop through every key in a VBA dictionary, use For Each key In dict.Keys, declaring key as a Variant. Inside the…
- VBA Dictionary For Each: Loop Through Keys and ItemsIn VBA, use For Each key In dict.Keys to loop through a Scripting.Dictionary’s keys, then read each value with dict(key). You can…
- VBA Dictionary Exists: Check Whether a Key Is PresentYes. In VBA, a Scripting.Dictionary has an Exists method that returns True when a specified key is present and False when it…
- VBA Dictionary Exists and Add: How They WorkYes. In a VBA Dictionary, use Exists to check whether a key is already present and Add to insert a new key…
- VBA Dictionary: How It Works and When to Use ItYes. A VBA Dictionary exists as the Scripting.Dictionary object: a key-value container that lets a macro store items under unique keys and…