Skip to content
- Excel VBA Fast Loop: Speed Up Repetitive Macro CodeTo make an Excel VBA loop fast, avoid reading or writing worksheet cells one at a time. Read the needed range into…VBA & macros
- Excel VBA Factorial Function: Code, Limits, and UseExcel already calculates factorials with the FACT worksheet function, but you can also create a VBA function for a reusable custom calculation.…VBA & macros
- Excel VBA: Extract the Year from a Date in a WorksheetTo extract a year from a date in Excel VBA, use the built-in Year function: pass it a valid date value, and…VBA & macros
- Excel VBA: Extract Text From a StringTo extract text from a string in Excel VBA, locate the relevant characters with InStr and return them with Mid$. For example,…VBA & macros
- Excel VBA: Export a Worksheet to a New FileIn Excel for Microsoft 365 on Windows, VBA can export a worksheet by copying it into a new workbook and saving that…VBA & macros
- Excel VBA: Export a Workbook to a New File FormatTo export an Excel workbook with VBA, use Workbook.SaveAs to save the open workbook in a different file format, or Workbook.SaveCopyAs to…VBA & macros
- Excel VBA Export Range to CSV, Text, or Another SheetTo export an Excel range with VBA, copy it to a temporary workbook and save that workbook as a CSV file; for…VBA & macros
- Excel VBA: How to Exit a For Next Loop Early in Your MacroYes. In Excel VBA, put Exit For inside a For...Next loop to leave it as soon as a condition is met; execution…VBA & macros
- Excel VBA: How to End a LoopTo end a VBA loop early, use Exit For inside a For loop or Exit Do inside a Do loop. Use Next…VBA & macros
- Excel VBA Erase Array: What It Does and When to Use ItIn Excel VBA, use Erase arrayName to reset an array: it releases the allocated storage of a dynamic array, but resets the…VBA & macros
- 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…VBA & macros
- 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;…VBA & macros
- 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,…VBA & macros
- 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 =…VBA & macros
- 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…VBA & macros
- 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…VBA & macros
- 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…VBA & macros
- 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…VBA & macros
- 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…VBA & macros
- 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…VBA & macros
- 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…VBA & macros
- 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…VBA & macros
- 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…VBA & macros
- 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…VBA & macros
- 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…VBA & macros
- 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…VBA & macros
- 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,…VBA & macros
- 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…VBA & macros
- 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…VBA & macros
- 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…VBA & macros