VBA & macros
Automate repeat work with macros and VBA code.
- Excel VBA Date and Time Stamp: Add Fixed TimestampsTo add a fixed date-and-time stamp with Excel VBA, assign Now to a cell and apply a date-time number format. For an…
- Excel VBA Date Type: Storage, Range, and ExamplesIn Excel VBA, Date is a built-in data type for storing a calendar date, a time, or both. Declare a variable with…
- Excel VBA Date Picker UserForm: Build One in ExcelTo make an Excel VBA date picker UserForm, create a modal UserForm with month-navigation buttons and a calendar grid, then write the…
- Excel VBA Date Now: Get Current Date and Time in MacrosIn Excel VBA, use Now to get the current date and time from the computer’s system clock. For the date alone, use…
- Excel VBA Date Picker: Controls, Options, and FixesExcel for Microsoft 365 on Windows does not include a universal VBA date-picker control that you can simply add to any cell.…
- Excel VBA Date Object: Dates, Times, and Examples ExplainedIn Excel VBA, Date is a built-in data type for storing a calendar date and, optionally, a time; it is not an…
- Excel VBA Date and Time Functions: A Practical GuideExcel VBA’s main current-date and time functions are Date, Time, and Now; use DateSerial and TimeSerial to build date and time values,…
- Excel VBA Date Today: How to Insert the Current DateIn Excel VBA, use the built-in Date function to get today’s date. To put it in a worksheet cell, assign Date to…
- Excel VBA Date Math: Add, Subtract, and Compare DatesIn Excel VBA, subtract one Date value from another to get the elapsed time in days, and use DateAdd to add a…
- Excel VBA Database: How It Works and When to Use OneAn Excel VBA database is a structured set of records kept in an Excel workbook, with Visual Basic for Applications (VBA) code…
- Excel VBA Database Connections: Setup, Code, and SafetyExcel VBA can connect to a database on Windows by using a data provider, opening a connection, and sending SQL through ADO…
- Excel VBA Data Validation Custom Formula: How to Use ItIn Excel VBA, create custom data validation with the Validation.Add method, setting Type:=xlValidateCustom and supplying a formula that evaluates to TRUE for…
- Excel VBA Data Validation: Create and Enforce RulesExcel VBA data validation lets a macro add, change, or remove the rules that control what users can enter in worksheet cells.…
- Excel VBA Data Entry Popup: Build a Simple UserFormYes. In Excel for Microsoft 365 on Windows, the usual way to create a VBA data-entry popup is to build a UserForm,…
- Excel VBA Refresh All: How to Update Every ConnectionTo refresh all supported external data connections and PivotTable reports in an Excel workbook with VBA, call ThisWorkbook.RefreshAll (or the workbook you…
- Excel VBA Data Entry: Forms, Validation, and MacrosExcel VBA data entry uses Visual Basic for Applications to collect, check, and write information in a workbook. For a simple setup,…
- Excel VBA Data Entry Forms: Setup, Code, and TipsAn Excel VBA data entry form is a custom window for collecting information and writing it to a worksheet, usually one record…
- Excel VBA Data Entry Form Template: Build and Use OneAn Excel VBA data entry form template is a reusable UserForm that collects values, checks them, and appends a complete record to…
- Excel VBA: Create a Histogram Automatically with a MacroYes. You can create a histogram with Excel VBA by counting numeric values into bins and plotting those counts, or by using…
- Excel VBA Create Named Range: Code, Scope, and TipsTo create a named range with Excel VBA, add a name to the workbook’s Names collection and set its RefersTo property to…
- Excel VBA Create Dictionary: Setup, Code, and Practical TipsTo create a Dictionary in Excel VBA on Windows, declare an object and set it to CreateObject("Scripting.Dictionary"). You can then add unique…
- Excel VBA: Convert a Variant to a StringIn Excel VBA, use CStr to convert a Variant value to a String: for example, textValue = CStr(value). Check first for special…
- Excel VBA: Count Occurrences in a StringTo count how many times one piece of text appears in another in Excel VBA, search repeatedly with InStr, advancing past each…
- Excel VBA: Create and Use an Array of StringsIn Excel VBA, declare a string array with Dim names() As String, give it a size with ReDim names(0 To 2), then…
- Excel VBA Concatenate Strings: Methods and ExamplesIn Excel VBA, concatenate strings with the ampersand operator (&), which joins text values into one string. For example, firstName & "…
- Excel VBA Connection Strings: Providers and ExamplesExcel VBA does not have one universal connection-string provider: choose a provider that matches the data source and is installed on the…
- Excel VBA Comment Function: What It Does and How to Use ItExcel VBA has no single “comment function”: use an apostrophe (or Rem) to add a non-running comment to VBA code, and use…
- Excel VBA Code to Send an Email With an AttachmentTo send an email with an attachment from Excel on Windows, use VBA to create a message through classic Outlook, add the…
- Excel VBA: Loop Through Cells in a RangeTo loop through every cell in an Excel range with VBA, use a For Each loop and a Range variable: For Each…
- Excel VBA Code to Sort Data by One or More Columns in ExcelTo sort data with Excel VBA, set the range to sort, add one or more sort keys, specify whether the first row…