Skip to content
- Excel VBA: How to Enable AutoFilterTo enable AutoFilter with VBA, select the worksheet range that includes the column headers and run its AutoFilter method: Worksheets("Data").Range("A1").CurrentRegion.AutoFilter. This displays…VBA & macros
- Excel VBA Dropdown List: Create and Update OneTo create an Excel VBA dropdown list, use VBA to add a Data Validation list to a cell with the Validation.Add method.…VBA & macros
- Excel VBA Sub vs Function: Key Differences and ExamplesIn Excel VBA, a Sub performs actions but does not return a value as its result; a Function calculates and returns a…VBA & macros
- Excel VBA: Delete a Worksheet Without a Prompt SafelyTo delete an Excel worksheet without the confirmation prompt, set Application.DisplayAlerts to False immediately before calling the worksheet’s Delete method, then restore…VBA & macros
- Excel VBA Delete Worksheet: Code, Safety, and OptionsTo delete a worksheet with Excel VBA, call that worksheet’s Delete method. Excel normally displays a confirmation prompt; you can suppress it…VBA & macros
- Excel VBA Delete a Workbook: Safe Methods and CodeYes. Excel VBA can delete a workbook file from disk, but the workbook must be closed first: Workbook.Close closes it, while VBA’s…VBA & macros
- Excel VBA Delete Whole Row: Safe Methods and ExamplesTo delete an entire worksheet row with VBA, use Rows(row_number).Delete, such as Rows(5).Delete for row 5. In a macro, qualify the row…VBA & macros
- Excel VBA: Delete Visible Rows After AutoFilterTo delete only the rows currently visible in a standard Excel AutoFilter, use VBA to take the filter range without its header,…VBA & macros
- Excel VBA: Delete Rows Based on CriteriaTo delete Excel rows that meet a condition, loop through the relevant rows from bottom to top and delete each match; working…VBA & macros
- Excel VBA: Delete a Row and Shift UpTo delete a complete worksheet row in Excel VBA and move the rows below it up, use Rows(rowNumber).Delete, such as ws.Rows(5).Delete. To…VBA & macros
- Excel VBA: Delete a Row If a Cell Is BlankYes. In Excel VBA, loop through the rows from the bottom upward and delete a row when the chosen cell is blank.…VBA & macros
- Excel VBA: Delete a Row from a TableTo delete a data row from an Excel table with VBA, use the table’s ListRows collection: for example, tbl.ListRows(3).Delete removes the third…VBA & macros
- Excel VBA: Delete Rows Based on a Cell Value MatchTo delete worksheet rows when a cell matches a value, loop upward from the last used row and delete each match. In…VBA & macros
- Excel VBA: Delete a Range of Rows by Number or MatchTo delete worksheet rows with Excel VBA, use Rows("3:7").Delete for rows 3 through 7, or qualify the range with a worksheet, such…VBA & macros
- Excel VBA: How to Delete the Current RowTo delete the worksheet row containing the active cell, use VBA’s ActiveCell.EntireRow.Delete method. For a safer macro that asks before deleting, save…VBA & macros
- Excel VBA: Delete a PivotTable SafelyTo delete a PivotTable with VBA, clear its full report range: use pt.TableRange2.Clear after setting pt to the PivotTable you want to…VBA & macros
- Excel VBA: How to Delete Column and Cell Ranges SafelyTo delete entire columns with Excel VBA, use a worksheet-qualified range such as ws.Columns("B:D").Delete. To delete only cells within a range, use…VBA & macros
- Excel VBA: How to Delete a Worksheet ButtonTo delete a button from an Excel worksheet, select the button itself and press Delete; for a Form Control button, right-click it…VBA & macros
- Excel VBA: Delete the Active Row SafelyTo delete the active row with Excel VBA, use ActiveCell.EntireRow.Delete; this removes the entire worksheet row containing the selected cell and shifts…VBA & macros
- Excel VBA: Get the Day of the Week from a Date ValueIn Excel VBA, use Weekday to get a date’s weekday number and WeekdayName to turn that number into a name. For example,…VBA & macros
- Excel VBA Day From Date: Weekday Numbers and NamesIn Excel VBA, use Day(dateValue) to return the day of the month, such as 14, and Weekday(dateValue, vbMonday) to return the day…VBA & macros
- Excel VBA Date to Number: Convert Dates to SerialsIn Excel VBA, convert a Date value to a number with CDbl(dateValue). The result is a serial value: its whole-number part represents…VBA & macros
- Excel VBA Date and Time Variable TypesIn Excel VBA, use the Date data type for a calendar date, a time, or a date-and-time value; it stores all three…VBA & macros
- Excel VBA Date Difference: Calculate Days and MonthsIn Excel VBA, use DateDiff to count calendar boundaries between two dates, for example DateDiff("d", startDate, endDate) for days or DateDiff("m", startDate,…VBA & macros
- Excel VBA Data Validation List From a Range in CellsTo create an Excel drop-down list from a range with VBA, use the target cell’s Validation.Add method and set Type:=xlValidateList and Formula1…VBA & macros
- Excel VBA Data Validation List: Setup and ExamplesIn Excel for Microsoft 365 on Windows, create a VBA dropdown by applying data validation with Type:=xlValidateList and setting Formula1 to either…VBA & macros
- Excel VBA Data Validation Drop-Down Lists: How to Build ThemTo create an Excel data-validation drop-down list with VBA, apply the xlValidateList validation type to the target cells and set its source…VBA & macros
- Excel VBA Current Worksheet: ActiveSheet ExplainedIn Excel VBA, the current worksheet is usually the sheet the user is looking at, and VBA refers to it as ActiveSheet.…VBA & macros
- Excel VBA Current Date and Time: Use Now, Date, and TimeIn Excel VBA, use Now to get the current date and time, Date for the current date, or Time for the current…VBA & macros
- Excel VBA Current Date: Date, Now, Formatting, and ExamplesIn Excel VBA, use Date to get the computer’s current date, without a time; use Now to get the current date and…VBA & macros