VBA & macros
Automate repeat work with macros and VBA code.
- Add a Hyperlink to a VBA MsgBox in ExcelYou cannot add a genuinely clickable hyperlink inside Excel VBA’s built-in MsgBox: it displays plain text and its standard buttons return choices…
- Excel VBA: How to Use Not IsErrorIn Excel VBA, write If Not IsError(value) Then to test whether a value is not an Excel error value. The VBA function…
- Automatically Add Comments to Excel Cells with VBAYes. In desktop Excel, VBA can automatically add a note to a cell with Range.AddComment; in current Microsoft 365 versions, VBA can…
- Excel VBA: How to Add a Threaded Comment to a CellIn Excel for Microsoft 365 on Windows, add a threaded comment to a cell with the VBA method Range.AddCommentThreaded. For example, ActiveCell.AddCommentThreaded…
- Excel VBA Worksheet Attributes: Properties and ExamplesIn Excel VBA, “worksheet attributes” usually means the properties of a Worksheet object: values that describe or control a sheet, such as…
- Option Button in Excel VBA: Add, Group, and Use ItYes. In Excel for Microsoft 365 on Windows, add an option button from Developer > Insert, then choose either a Form Control…
- Define a Function in Excel VBA: Syntax and ExamplesTo define a function in Excel VBA, write a Function procedure in a standard VBA module, give it a name and any…
- Convert an Excel Range to HTML in VBATo convert a range to a formatted HTML file in Excel for Microsoft 365 on Windows, add a VBA macro that publishes…
- Create a Toggle Button in Excel VBA: Setup and CodeTo create a toggle button in Excel VBA on Windows, choose Developer > Insert > Toggle Button under ActiveX Controls, turn on…
- Defender Risky Action Excel Macro: Meaning and Safe StepsYes—Microsoft Defender can flag an Excel macro as risky or block an action it tries to take. That warning does not, by…
- Excel UserForm Scrollbar: Setup, Events, and ExamplesTo use a scrollbar on an Excel UserForm, add a ScrollBar control in the Visual Basic Editor, set its Min, Max, SmallChange,…
- Scrollbar in Excel VBA: Forms, Controls, and CodeIn Excel VBA, a scrollbar can mean a worksheet navigation bar, a scroll bar control linked to a cell, or a control…
- Excel Macro to Email Files From a Folder AutomaticallyIn Excel for Microsoft 365 on Windows, a VBA macro can let you choose a folder, attach its files to an Outlook…
- Excel VBA TextBox for Data Entry: Setup and CodeYes. In Excel for Microsoft 365 on Windows, a VBA TextBox can collect information through a UserForm or an ActiveX control on…
- SAP Analysis Excel VBA: Setup, Examples, and LimitsYes—VBA can automate SAP Analysis for Microsoft Office (often called Analysis Office or AO) from Excel, using the add-in’s documented API to…
- Sudoku Solver in Excel: Setup, Methods, and VBA CodeYes—Excel can solve Sudoku. For a practical solver, enter the puzzle in cells B2:J10 and run a short VBA macro that checks…
- Excel Analysis ToolPak VBA: Setup, Limits, and UseYes—Excel can work with the Analysis ToolPak and VBA, but the add-in is not a universal VBA interface to every command in…
- How to Highlight Duplicates in Excel VBA with a MacroTo highlight duplicate values with VBA, select the cells you want to check, run a macro that counts each nonblank value, and…
- Clear Excel VBA: Contents, Formats, and CellsTo clear cells with Excel VBA, use Range("B2:D20").ClearContents to remove values and formulas while keeping formatting, or Range("B2:D20").Clear to remove cell contents…
- Excel VBA MsgBox: Syntax, Buttons, and ExamplesExcel VBA’s MsgBox function displays a dialog box with a message, optional buttons and icon, and an optional title. Call it from…
- Excel VBA Range: How to Select, Read, and Edit CellsIn Excel VBA, a Range is an object that refers to one cell, a group of cells, or a named range. Use…
- Columns in Excel VBA: Select, Count, and Use ThemIn Excel VBA, use a worksheet’s Columns property to refer to one or more entire worksheet columns, such as ws.Columns("B:B") or ws.Columns(2).…
- Excel VBA Rows: Select, Count, and Manage Worksheet RowsIn Excel VBA, Rows refers to worksheet rows or the rows within a specified range. For example, Worksheets("Data").Rows(5) addresses the entire fifth…
- Excel SEQUENCE Macro: Generate Number Series in VBAIf you want a sequence of numbers in Excel, the simplest option is usually the SEQUENCE worksheet function, not a macro: enter…
- Excel VBA Offset: Move a Range by Rows and Columns in a MacroIn an Excel VBA macro, use the Offset property to refer to a cell or range a chosen number of rows and…
- Excel VBA Offset: How to Reference Nearby CellsIn Excel VBA, Offset refers to a cell or range a chosen number of rows and columns away from another range. For…
- Excel Sum by Color: Formulas, Filters, and VBAExcel has no built-in SUM function that adds cells based on their fill color. To total cells of a color, filter the…
- Round Up in Excel VBA: Methods, Rules, and ExamplesTo round numbers up in Excel VBA using Excel’s familiar “away from zero” rule, call Application.WorksheetFunction.RoundUp(number, num_digits). For example, it can turn…
- Excel VBA Weekday: Syntax, Return Values, and ExamplesIn Excel VBA, use Weekday(date, firstdayofweek) to get a date’s position in the week as a number from 1 to 7. For…
- Excel VBA Date: Get, Store, and Work With DatesIn Excel VBA, Date returns the current date from the computer’s system clock, without a time component; assign it to a variable…