Skip to content
- 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
- Excel VBA: Fill a Formula Down to the Last Data RowTo fill a formula in B2 down through the last row that has data in column A, find that row with End(xlUp)…VBA & macros
- Excel VBA File Open Error: Causes and FixesAn Excel VBA file-open error usually means Excel cannot access the file at the path supplied to Workbooks.Open, or it cannot read…VBA & macros
- Excel VBA Export Chart: Image, PDF, and OptionsTo export an embedded Excel chart with VBA as a PNG, call its Chart.Export method and specify a file name and image…VBA & macros
- Excel VBA Subscript Out of Range: Causes and FixesExcel VBA “Run-time error 9: Subscript out of range” means your code asked for an item that does not exist at the…VBA & macros
- Excel VBA Sub or Function Not Defined? Fix It“Sub or Function not defined” is a VBA compile error: Excel cannot resolve the name of a procedure or function used by…VBA & macros
- Excel VBA Error Numbers: Common Codes, Causes, and Fixes ExplainedExcel VBA error numbers are numeric identifiers that help you diagnose a problem when a macro fails; the number and its description…VBA & macros
- Excel VBA Error Message Box: Show and Handle ErrorsAn Excel VBA error message box is usually created with the MsgBox function; use On Error GoTo to catch a runtime error…VBA & macros
- Excel VBA Error Messages: Causes, Codes, and FixesAn Excel VBA error message means the macro could not compile, run an instruction, or complete an operation as written. Read the…VBA & macros
- Excel VBA Error Line Number: How to Find ItExcel VBA does not automatically show a source line number in a runtime error message. To identify the failing line in code,…VBA & macros
- Excel VBA Error Handling: On Error, Examples, and Best PracticesExcel VBA error handling lets a macro respond to runtime problems instead of stopping unexpectedly. Use On Error GoTo Handler for a…VBA & macros