Skip to content
- Excel VBA On Error Resume Next: Safe Use and ExamplesIn Excel VBA, On Error Resume Next tells a procedure to continue with the statement immediately after the one that caused a…VBA & macros
- Excel VBA On Error GoTo Next: What It Really DoesExcel VBA does not have an On Error GoTo Next statement. The syntax people usually mean is On Error Resume Next: it…VBA & macros
- Excel VBA On Error GoTo: Handle Macro Errors the Right WayIn Excel VBA, On Error GoTo label tells a procedure to jump to a named error-handling section when a run-time error occurs.…VBA & macros
- Excel VBA On Error GoTo: How Error Handling WorksIn Excel VBA, On Error GoTo LabelName sends execution to a named error-handling section when a run-time error occurs in that procedure;…VBA & macros
- Excel VBA On Error Exit Sub: How Error Handling WorksIn Excel VBA, On Error Exit Sub is not a valid error-handling statement. To stop a procedure after an error, route execution…VBA & macros
- Excel VBA Macro to Filter Data: Code and ExamplesTo filter a worksheet with an Excel VBA macro, define the full range including its header row, then call its AutoFilter method…VBA & macros
- Excel VBA Next Without For Error: Causes and FixesThe Excel VBA compile error “Next without For” means VBA has reached a Next statement without finding a matching, currently open For…VBA & macros
- Excel VBA Macro to Copy Data Between SheetsTo copy data between worksheets with an Excel VBA macro, assign the source range’s values to a destination range of the same…VBA & macros
- Excel VBA Out of Memory Error: Causes and FixesAn Excel VBA “Out of memory” error usually means Excel cannot allocate enough usable memory for the macro’s next operation—not necessarily that…VBA & macros
- Excel VBA Macro Best Practices for Reliable WorkbooksFor reliable Excel VBA macros, make each procedure do one clear job, declare variables with Option Explicit, qualify workbook and worksheet references,…VBA & macros
- Excel VBA on Mac: How to Open Files with a MacroYes. Excel for Mac can open a workbook from VBA with Workbooks.Open; give it the file’s full Mac path, such as /Users/yourname/Documents/Report.xlsx.…VBA & macros
- Excel VBA: Loop Through All Files in a FolderTo loop through files in a folder with Excel VBA, use the Dir function to get the first matching file, then call…VBA & macros
- Excel VBA: Loop Through Files in a Folder with DirIn Excel VBA, use the Dir function to find files that match a folder path and filename pattern, then repeat with Dir$()…VBA & macros
- Excel VBA Insert Image: Code and OptionsTo insert an image with Excel VBA, call the worksheet’s Shapes.AddPicture method, supplying the image file path and its position. Use LinkToFile:=msoFalse…VBA & macros
- Excel VBA If Statement Without Then: What Works?No: an Excel VBA If statement must include the keyword Then. Write If condition Then before the action or block of code;…VBA & macros
- Excel VBA: How to Check Whether Cell Colors Match ExactlyYes. In Excel VBA, compare the cells’ Interior.Color values; they are numeric color values, so an equality test tells you whether their…VBA & macros
- Excel VBA: How to Stop a Running MacroTo stop a running Excel VBA macro on Windows, press Ctrl+Break; on a Mac, press Command+period (.). If Excel does not respond…VBA & macros
- Excel VBA: Get the Last Row Number ReliablyTo get the last nonempty row in a particular column, start at the bottom of that worksheet column and move upward to…VBA & macros
- Excel VBA Format Number to 2 Decimal PlacesTo make Excel display numbers with exactly two decimal places, set a cell or range’s VBA NumberFormat property to "0.00". For example,…VBA & macros
- Excel VBA Format Cell Color: Fill, Font, and RulesTo format a cell’s fill color with Excel VBA, set its Interior.Color property; for example, Range("A1").Interior.Color = RGB(255, 0, 0) makes A1’s…VBA & macros
- Excel VBA Format Cell as Number: Examples and TipsTo format cells as numbers with Excel VBA, assign a number-format code to the range’s NumberFormat property. For example, Range("B2:B100").NumberFormat = "#,##0.00"…VBA & macros
- Excel VBA: Find the Last Used Row in Any WorksheetIn Excel VBA, use the worksheet’s Find method to locate the last cell containing content anywhere on the sheet, then read its…VBA & macros
- Excel VBA: Find the Last Row With a Specific ValueTo find the last row containing a particular value, search the target column with VBA’s Range.Find method, set SearchDirection:=xlPrevious, and check whether…VBA & macros
- Excel VBA: Find the Last Row with Data in a RangeTo find the last row containing data within a particular Excel range, use the range’s Find method with a bottom-to-top, row-wise search.…VBA & macros
- Excel VBA: Find the Last Row of a TableTo get the last data row of an Excel table (a VBA ListObject), use its DataBodyRange: the last worksheet row is tbl.DataBodyRange.Row…VBA & macros
- Excel VBA: Find the Last Row in a RangeTo find the last populated row in a specified Excel VBA range, use the range’s Find method with SearchOrder:=xlByRows and SearchDirection:=xlPrevious. For…VBA & macros
- Excel VBA Find Last Populated Row: Reliable MethodsIn Excel VBA, use ws.Cells(ws.Rows.Count, "A").End(xlUp).Row to find the last nonempty cell in column A. If you need the last populated row…VBA & macros
- Excel VBA: How to Find the Last Used Column in a RowIn Excel VBA, find the last used column in a row by starting at the worksheet’s final column and moving left: ws.Cells(rowNum,…VBA & macros
- Excel VBA Filter Rows Containing Specific TextTo show only rows whose cells contain particular text, use Excel VBA’s AutoFilter method with a wildcard criterion such as *urgent*. For…VBA & macros
- Excel VBA Filter Multiple Criteria: Examples and CodeTo filter by multiple criteria in Excel VBA, use the range’s AutoFilter method: apply one criterion per field for conditions that must…VBA & macros