VBA & macros
Automate repeat work with macros and VBA code.
- Excel VBA Empty String: How to Test, Set, and ClearIn Excel VBA, an empty string is a string with zero characters, written as "". Use Len(value) = 0 to test whether…
- Excel VBA: How to Edit a Worksheet with VBA MacrosTo edit a worksheet with Excel VBA, write a macro that identifies the worksheet and changes its cells, formatting, or structure—for example,…
- Excel VBA End Function: How to End and Exit FunctionsIn Excel VBA, finish a function procedure with End Function. To leave the function early from inside its code, use Exit Function;…
- Excel VBA: How to Edit a PivotTableYes. In Excel for Microsoft 365 on Windows, VBA can edit a PivotTable by changing its fields, layout, filters, formatting, or source…
- Excel VBA Dynamic Worksheet Names: How They WorkIn Excel VBA, make a worksheet name dynamic by storing the desired tab name in a string variable and using that variable…
- Excel VBA Edit Range: How to Change Cell Values SafelyTo edit a cell or range with Excel VBA, assign a value or formula to a Range object, for example Worksheets("Sheet1").Range("A1").Value =…
- Excel VBA Dynamic Pivot Tables: Build and Refresh ThemYes. To make an Excel VBA pivot table adapt when records are added, put the source data in an Excel Table, create…
- Excel VBA Double Quotes in Strings: How to Write ThemIn Excel VBA, put a literal double quote inside a string by writing two double quotes next to each other: "". For…
- Excel VBA Dim ws As Worksheet: Meaning and ExamplesDim ws As Worksheet declares a VBA variable named ws that can refer to an Excel worksheet; it does not select or…
- Excel VBA Dir Function: Find Files and FoldersIn Excel VBA, the Dir function finds a file or folder that matches a path and optional wildcard pattern. Call it once…
- Excel VBA: Display a Variable Value in a MsgBoxIn Excel VBA, display a variable in a message box by passing it to MsgBox, for example MsgBox customerName. To combine a…
- Excel VBA Dim As Workbook: Declare and Use ItIn Excel VBA, declare a workbook variable with Dim wb As Workbook, then assign it to an open or newly created workbook…
- Excel VBA Dim Worksheet: How to Declare a SheetIn Excel VBA, declare a worksheet variable with Dim ws As Worksheet, then use Set ws = ThisWorkbook.Worksheets("Data") to point it at…
- Excel VBA Dim Array: Declare and Use ArraysIn Excel VBA, use Dim to declare an array: for example, Dim scores(1 To 10) As Long creates a fixed array of…
- Excel VBA Dim As Date: Declare and Use Date VariablesIn Excel VBA, declare a date variable with Dim variableName As Date, such as Dim dueDate As Date. The Date type stores…
- Excel VBA Dictionary of Arrays: How to Store and Use DataYes—you can store arrays as values in an Excel VBA Dictionary. On Windows, create a Scripting.Dictionary, assign an array to a key,…
- Excel VBA Dictionary Remove: Methods and Examples ExplainedTo remove one entry from an Excel VBA Dictionary, call dict.Remove key; to remove every entry but keep the dictionary object, call…
- Excel VBA Dictionary Items: How to Read and Loop Through ThemIn Excel VBA, a Dictionary’s Item property returns the value stored under a particular key, while its Items method returns an array…
- Excel VBA Dictionary Keys: Add, Find, and Manage ItemsIn Excel VBA, a dictionary key is a unique identifier used to store and retrieve a corresponding value. Add a key-value pair…
- Excel VBA Dictionary Length: Count Entries and KeysIn Excel VBA, use a Dictionary’s Count property to find how many key-item pairs it contains. If by “length” you mean the…
- Excel VBA Dictionary For Each: Looping Through KeysIn Excel VBA, For Each loops through the keys of a Scripting.Dictionary when you write For Each key In dict. Declare the…
- Excel VBA Dictionary Count: What .Count ReturnsIn Excel VBA, get the number of entries in a Dictionary with its .Count property: use dict.Count. It returns the number of…
- Excel VBA Dictionary: How It Works and When to Use ItYes, Excel VBA can use a Dictionary on Windows, but VBA does not include a native Dictionary type. The commonly used option…
- Excel VBA Dictionary Add Array: Store and Retrieve ValuesYes. In Excel VBA, add an array to a Dictionary by passing it as the item in the Dictionary’s Add method, then…
- Excel VBA Dictionary vs Collection: Which Should You Use?In Excel VBA, use a Scripting.Dictionary when you need unique keys, quick key-based lookups, or an Exists check; use a Collection when…
- Excel VBA UserForm Dialogs: How to Build and Show OneAn Excel VBA UserForm is a custom dialog you design to collect information, display choices, or guide a user through a task.…
- Excel VBA Dictionary Add: Syntax, Examples, and TipsIn Excel VBA, add an entry to a Dictionary with dict.Add key, item, after creating the Dictionary object. The key must be…
- Excel VBA Date Value: Serials, Types, and ExamplesIn Excel VBA, a Date value is a date-and-time value that VBA stores as a number; use the Date data type for…
- Excel VBA Date Variable: Types, Examples, and TipsIn Excel VBA, declare a date variable with Dim myDate As Date. A VBA Date variable can hold a calendar date, a…
- Excel VBA Derivative: Calculate a Function’s Rate of ChangeExcel VBA has no built-in function that symbolically derives any formula. If by “derive” you mean find a calculus derivative, you can…