VBA & macros
Automate repeat work with macros and VBA code.
- VBA Date Variables: How to Declare and Use ThemIn VBA, declare a date variable with Dim eventDate As Date. A Date variable can hold a calendar date, a time, or…
- VBA Functions: What They Are and How to Use ThemA function in VBA is a named procedure that performs a task and returns a value. You can call one from another…
- Excel Macro Settings Greyed Out? Causes and How to FixIf Excel macro settings are greyed out, they are usually being controlled by an administrator or you are using Excel for the…
- Conditional Formatting VBA: Rules, Examples, and TipsIn Excel for Microsoft 365 on Windows, VBA creates conditional formatting by adding a rule to a range’s FormatConditions collection. For example,…
- Create a Dictionary in VBA: Keys, Values, and Code ExamplesTo create a dictionary in VBA for Excel on Windows, declare an object and use CreateObject("Scripting.Dictionary"). Add entries as key–value pairs, then…
- Combobox in VBA UserForms: Setup, Code, and TipsA ComboBox in a VBA UserForm lets a person choose an item from a drop-down list, and it can also allow typed…
- Excel Macro Script: How It Works and How to Create OneAn Excel macro script is a set of instructions that automates actions in a workbook; in desktop Excel, macros are commonly written…
- Excel Macro Security Settings: What to Choose and WhyIn Excel for Microsoft 365 on Windows, go to File > Options > Trust Center > Trust Center Settings > Macro Settings…
- Excel Macro Refresh All: How to Update Workbook DataIn Excel for Microsoft 365 on Windows, use the VBA method ThisWorkbook.RefreshAll to request a refresh of the workbook’s refreshable external data…
- Excel Macro: Refresh All Data ConnectionsYes. In Excel for Microsoft 365 on Windows, a VBA macro can refresh the workbook’s refreshable external data ranges and PivotTable reports…
- Close MsgBox VBA: Reliable Ways to Dismiss a DialogTo close a VBA MsgBox, click one of its buttons or use a keyboard action the dialog supports; the call then returns…
- VBA Break Function: How to Pause or Stop a Running MacroVBA does not have a built-in Break function or statement. To interrupt a running macro, use the Visual Basic Editor’s Break command…
- Excel Macro Recorder: How It Works and When to Use ItExcel’s Macro Recorder captures many worksheet actions and turns them into VBA code that you can run again to repeat those actions.…
- Can You Exit Multiple Loops in VBA? Practical MethodsYes, you can stop multiple nested loops in VBA, but there is no single Exit All statement. Exit For and Exit Do…
- Excel Macro Range: How to Reference and Use RangesAn Excel macro range is one cell or a group of cells that VBA can read, change, format, or otherwise work with.…
- Basic For Loop in VBA: Syntax, Examples, and Usage GuideA basic For loop in VBA repeats a block of code a set number of times. Write For counter = start To…
- Excel Macro Programming: What It Is and How It WorksExcel macro programming means creating instructions that automate tasks in a workbook, most commonly with Visual Basic for Applications (VBA). You can…
- Autofit VBA Range: Columns, Rows, and ExamplesIn Excel VBA, use the AutoFit method to size worksheet columns or rows to fit their contents. For a cell range, call…
- Excel Macro Location: Where VBA Code Is StoredIn Excel for Microsoft 365 on Windows, a macro is usually stored as VBA code inside the workbook that contains it. To…
- Excel Macro If Statement: VBA Syntax and Examples GuideAn Excel macro uses VBA’s If...Then...Else statement to make a decision and run different instructions depending on whether a condition is true…
- Excel Macro Language: VBA, Office Scripts, and MoreExcel’s traditional macro language is Visual Basic for Applications (VBA), which automates tasks in the desktop app. Microsoft 365 also offers Office…
- VBA AutoFilter Field 1: What It MeansIn Excel VBA, Field:=1 tells AutoFilter to filter the first column in the filter range—not necessarily worksheet column A. For example, if…
- Excel Macro GoTo: VBA Labels, Ranges, and ExamplesIn an Excel macro, GoTo can mean either VBA’s GoTo label statement, which jumps to a named line in the same procedure,…
- Excel Macro to Get Row Count: Choose the Right VBA MethodTo count data rows in an Excel macro, count a column that has one nonblank entry for every record; for example, use…
- Excel Macro: Generate a Summary AutomaticallyYes. In Excel for Microsoft 365 on Windows, a VBA macro can read a data table, group rows by a category, add…
- Add Worksheet VBA: Excel Methods and ExamplesTo add a worksheet with VBA in Excel, use Worksheets.Add, then assign the new sheet a name. For example, a macro can…
- Access VBA Sort: Forms, Queries, and RecordsetsTo sort records in an Access form with VBA, set the form’s OrderBy property and turn sorting on: for example, Me.OrderBy =…
- Excel Macro For Loop: Examples and Common FixesAn Excel macro for loop is a VBA loop that repeats instructions for a set of items or a known number of…
- Access VBA: How to Send EmailYes. Access VBA can send email either through DoCmd.SendObject, which uses the computer’s configured MAPI email client, or by automating classic Outlook…
- Excel Macro File: How to Save, Open, and Use It SafelyAn Excel macro file is a workbook that can store VBA code to automate tasks; the usual format is an Excel Macro-Enabled…