Skip to content
- Excel VBA Copy and Paste Formatting Without Changing ValuesTo copy formatting with Excel VBA without copying cell values or formulas, copy the source range and paste with xlPasteFormats. For example,…VBA & macros
- Excel VBA Convert Date to Number: Serial ValuesYes. Excel dates are stored as serial numbers, so VBA can read a date cell’s underlying number with Range.Value2; to display that…VBA & macros
- Excel VBA Collection vs Dictionary: Which Should You Use?Use a VBA Collection when you need an ordered list of items, optionally addressed by unique string keys; use a Scripting.Dictionary when…VBA & macros
- Excel VBA: How to Close a UserForm After a Button ClickTo close an Excel VBA UserForm when a button is clicked, put Me.Hide in that button’s Click event to hide the form,…VBA & macros
- Excel VBA: Clear the Clipboard After Copy and PasteTo clear Excel’s copy mode after a VBA copy-and-paste operation, run Application.CutCopyMode = False after the paste. This removes Excel’s moving dashed…VBA & macros
- Excel VBA: Check Whether a Worksheet Name Exists SafelyTo check whether a worksheet exists in Excel VBA, try to assign the named item from the target workbook’s Worksheets collection, then…VBA & macros
- Excel VBA: Check Whether a Worksheet ExistsTo check whether a worksheet exists in Excel VBA, loop through the target workbook’s Worksheets collection and compare each sheet name. This…VBA & macros
- Excel VBA: How to Check Whether a Workbook Is OpenTo check whether a workbook is open in Excel VBA, loop through Application.Workbooks and compare each open workbook’s name or full path…VBA & macros
- Excel VBA: Check Whether a String Is Empty or BlankIn Excel VBA, use Len(text) = 0 to check whether a string has no characters. If you also want to treat spaces…VBA & macros
- Excel VBA: Check If a String Contains a Substring in a CellIn Excel VBA, use InStr to check whether one string contains another: it returns a position greater than zero when it finds…VBA & macros
- Excel VBA: Check Whether a Dictionary Key ExistsUse a VBA Dictionary’s Exists method to check for a key: If dict.Exists(keyToFind) Then. It returns True when the key is present…VBA & macros
- Excel VBA: Check If AutoFilter Is Active on a SheetIn Excel VBA, check Worksheet.AutoFilterMode to find out whether AutoFilter arrows are displayed, and check Worksheet.FilterMode to find out whether the worksheet…VBA & macros
- Excel VBA: Check Whether a Dynamic Array Is AllocatedNo—VBA arrays are not objects, so If myArray Is Nothing is not a valid way to test one. To check a dynamic…VBA & macros
- Excel VBA MsgBox Font Size: Change It or Use a FormYou cannot set the font size of Excel’s built-in VBA MsgBox directly: its text uses the standard Windows dialog appearance, and VBA…VBA & macros
- Excel VBA: Center a UserForm on Screen AutomaticallyTo center an Excel VBA UserForm on the screen, set its StartUpPosition property to 2 - CenterScreen before displaying it. You can…VBA & macros
- Excel VBA Can’t Find Project or Library? Fix the ErrorIf Excel VBA says “Can’t find project or library,” the VBA project usually has a reference to a library that is missing,…VBA & macros
- Excel VBA Build Array: Methods, Examples, and LimitsTo build an array in Excel VBA, assign the Array function to a Variant, or declare a typed array and fill its…VBA & macros
- Excel VBA: Bring a Workbook Window to the Front ReliablyTo bring an open workbook to the front with Excel VBA, activate Excel and then activate the workbook: call Application.Activate followed by…VBA & macros
- Excel VBA UserForm: Bring It to the FrontTo bring a modeless Excel VBA UserForm forward on Windows, show it with vbModeless, then use the Windows API SetWindowPos to move…VBA & macros
- Excel VBA Break Loop: Keyboard Shortcuts and FixesTo interrupt a running Excel VBA loop on Windows, press Ctrl+Break (sometimes labeled Pause/Break); on a Mac, press Command+Period (⌘.). Excel usually…VBA & macros
- Excel VBA AutoFilter Method Failed? Causes and FixesYes—“AutoFilter method of Range failed” is usually a VBA runtime error caused by an invalid or unsuitable range, an incorrect field number,…VBA & macros
- Excel VBA AutoFilter: Copy Visible Results to Another SheetYes. In Excel for Microsoft 365 on Windows, apply AutoFilter to the source range, then copy its visible cells to a destination;…VBA & macros
- Excel VBA Arrays vs Collections vs DictionariesIn Excel VBA, use an array for a compact, indexed set of values, a Collection for an ordered group of items you…VBA & macros
- Excel VBA Array Methods: Create, Resize, and SearchExcel VBA does not provide a single built-in “array methods” object: instead, it offers array functions and statements such as Array, Split,…VBA & macros
- Excel VBA Array Maximum Size: Limits and Practical TipsThere is no single, guaranteed maximum number of elements for an Excel VBA array: its usable size depends mainly on available memory,…VBA & macros
- Excel VBA: Highlight the Active CellTo highlight the active cell in Excel for Microsoft 365 on Windows, put a Worksheet_SelectionChange event in that worksheet’s code module and…VBA & macros
- Excel VBA Array Filter: Methods, Code, and ExamplesTo filter a one-dimensional array of strings in Excel VBA, use the built-in Filter function, for example Filter(names, "Ava", True, vbTextCompare). It…VBA & macros
- Excel VBA Array Delete: How to Remove Items SafelyIn Excel VBA, use Erase to clear an entire array; it does not remove just one element. To delete one item, shift…VBA & macros
- Excel VBA: Add a New Worksheet With a Specific NameIn Excel VBA, add a worksheet with Worksheets.Add, then set its Name property. For example, the key steps are Set ws =…VBA & macros
- Excel VBA Active Worksheet Reference ExplainedIn Excel VBA, use ActiveSheet to refer to the sheet currently active in the active workbook. For a dependable macro, assign that…VBA & macros