VBA & macros
Automate repeat work with macros and VBA code.
- Excel VBA: Add a Date to a Cell, Once or AutomaticallyTo add today’s date to a cell with Excel VBA, assign the VBA Date value to that cell, then set its display…
- Excel VBA: Add Days to a Date in Excel Cells and MacrosTo add days to a date in Excel VBA, use DateAdd("d", numberOfDays, dateValue) or add a whole number directly to a date…
- Excel VBA Absolute Value: How to Use AbsIn Excel VBA, use the built-in Abs function to return a number’s absolute value: Abs(number). For example, Abs(-12.5) returns 12.5; the function…
- Excel VBA Add AutoFilter: Code, Examples, and FixesTo add AutoFilter with Excel VBA, identify the header-and-data range and call its AutoFilter method: dataRange.AutoFilter. For example, a macro can use…
- Excel VBA ABS Function: Syntax and ExamplesIn Excel VBA, use the built-in Abs function to return a number’s absolute value: Abs(number). For example, Abs(-12.5) returns 12.5, while Abs(12.5)…
- Excel Solver VBA: Set Up and Run Optimization ModelsYes—Excel Solver can be controlled with VBA to set an objective, choose changing cells, add constraints, and run an optimization automatically. In…
- Excel Power Query and VBA: Differences, Uses, and ChoiceExcel Power Query and VBA solve different problems: use Power Query to connect to data and repeatably import, combine, and clean it;…
- Excel Power Pivot VBA: What You Can AutomateYes—VBA can automate useful parts of Excel Power Pivot, especially refreshing workbook data and updating reports built from the Data Model. It…
- Excel Not Responding During VBA? Causes and FixesIf Excel says Not Responding while VBA runs, it often means the macro is occupying Excel’s interface thread—not necessarily that Excel has…
- Trim in VBA: What It Removes and When to Use ItIn VBA, Trim is a standard built-in string function that removes ordinary spaces from the beginning and end of a string. For…
- How to Code Toggle Buttons in VBATo code a toggle button in Excel VBA, insert an ActiveX Toggle Button, open its worksheet code module, and write a Click…
- VBA Length of String: How Len WorksIn VBA, use the Len function to get the length of a string: Len(text) returns a Long count of its characters. It…
- VBA InputBox Example: Get and Validate User InputA VBA InputBox example can ask for a value, store the reply, and use it in a macro. For a simple text…
- VBA Dictionary If: Check Whether a Key ExistsTo check whether a key is in a VBA Dictionary, use its Exists method inside an If statement: If dict.Exists(key) Then. It…
- VBA Data Dictionary: How to Create and Use OneA VBA data dictionary is usually the Scripting.Dictionary object: a key-and-value store that lets a macro look up information by a unique…
- VBA Create Pivot Table From Table in ExcelYes. In Excel for Microsoft 365 on Windows, VBA can create a PivotTable directly from an Excel table (a ListObject) by building…
- VBA Array Example: Declare, Fill, and Loop Through DataA VBA array stores several related values under one variable name. For example, declare a three-item array with Dim items(1 To 3)…
- How to Open Visual Basic in Excel Using the VBA EditorIn Excel for Microsoft 365 on Windows, press Alt+F11 to open the Visual Basic Editor, or select Developer > Visual Basic. You…
- How to Open Macros in Excel and Enable Them SafelyTo run macros in Excel for Microsoft 365 on Windows, open a trusted macro-enabled workbook, select Enable Content if Excel shows a…
- How to Open VBA in Excel: Find and Use the VBA EditorTo open the VBA editor in Excel for Microsoft 365 on Windows, open a workbook and press Alt+F11. You can also select…
- How to Open the VBA Editor in Excel on Windows and MacIn Excel for Microsoft 365 on Windows, press Alt+F11 to open the Visual Basic for Applications (VBA) Editor. You can also open…
- How to Open the Macro Editor in ExcelIn Excel for Microsoft 365 on Windows, press Alt+F11 to open the Visual Basic Editor, where you can view and edit VBA…
- How to Open Macros in Excel and View or Run ThemTo open a macro in Excel for Microsoft 365 on Windows, open the workbook that contains it, then choose Developer > Macros,…
- How to Open Macro Code in Excel: A Step-by-Step GuideIn Excel for Microsoft 365 on Windows, press Alt+F11 to open the Visual Basic Editor, then use Project Explorer to locate and…
- Google Sheets Macros: Examples and How to Use ThemGoogle Sheets macros are saved actions you can replay to automate repetitive work, such as formatting a report, cleaning a copied list,…
- Google Sheets Macro Tracker: Build a Practical Food LogYes—Google Sheets can work as a flexible macro tracker: log foods and their calories, protein, carbohydrates, and fat, then use formulas to…
- Google Sheets Macro: How to Delete One Step by StepTo delete a macro in Google Sheets, open the spreadsheet in a desktop web browser and choose Extensions > Macros > Manage…
- Google Sheets Macro Language: Apps Script ExplainedGoogle Sheets macros use Google Apps Script, a scripting language based on JavaScript; there is no separate Google Sheets macro language. Recording…
- Google Sheets Macro Button: Create and Assign OneTo make a Google Sheets macro button, insert a drawing or an image over the cells, open its three-dot menu, choose Assign…
- Google Sheets Macro Converter: What It Does and LimitsA Google Sheets macro converter can help translate some Excel VBA macros into Google Apps Script, but it does not turn every…