Skip to content
- Excel VBA Functions That Return ArraysYes. In Excel VBA, declare the function as Variant, place an array in that Variant, and assign it to the function name;…VBA & macros
- Excel VBA Function Return: Values, Syntax, and ExamplesAn Excel VBA function returns a value by assigning that value to the function’s own name; VBA does not use a return…VBA & macros
- Excel VBA Function Output: Return Values and DisplayAn Excel VBA function outputs a value by assigning that value to the function’s name. That value appears in a worksheet cell…VBA & macros
- Excel VBA Optional Parameters: Syntax and ExamplesYes. In Excel VBA, declare an optional parameter with the Optional keyword, usually followed by a default value, such as Optional ByVal…VBA & macros
- Excel VBA Optional Arguments: How They WorkYes—Excel VBA procedures and functions can have optional arguments. Declare one with the Optional keyword; give typed arguments a default value, or…VBA & macros
- Excel VBA Function Not Updating Automatically? Fix ItIf an Excel VBA function is not updating automatically, first check Formulas > Calculation Options > Automatic, then press Ctrl+Alt+F9 to force…VBA & macros
- Excel VBA Function Not Showing Up? Fixes That WorkIf an Excel VBA function is not showing up, first check that it is a public function in a standard module in…VBA & macros
- Excel VBA Function Not Recognized? How to Fix ItIf Excel does not recognize a VBA function, first check that it is a Public Function in a standard module in a…VBA & macros
- Excel VBA Function Not Defined? Causes and Fixes ExplainedIf Excel VBA reports Sub or Function not defined, it cannot find the procedure named in the highlighted line. Check the spelling…VBA & macros
- Excel VBA Function Multiple Outputs: Practical MethodsYes. An Excel VBA function can provide multiple outputs by returning an array, or VBA code can use ByRef arguments or a…VBA & macros
- Excel VBA Minimum: Find the Smallest ValueIn Excel VBA, use Application.WorksheetFunction.Min to return the smallest value from a range or a set of numbers; VBA does not have…VBA & macros
- Excel VBA Function Key: Run Macros and Assign ShortcutsIn Excel VBA, press F5 in the Visual Basic Editor to run the current procedure; press F8 to step through it one…VBA & macros
- Excel VBA Expected Expression Error: Causes and FixesIn Excel VBA, Expected: expression is a compile error: VBA reached a place where it needs a value or calculation, but found…VBA & macros
- Excel VBA Exit Function: When and How to Use It SafelyIn Excel VBA, Exit Function stops the current function immediately and returns control to the statement that called it. Before using it,…VBA & macros
- Excel VBA Default Parameter Values and Optional ArgumentsIn Excel VBA, give a parameter a default by declaring it Optional and assigning a value in the procedure signature, such as…VBA & macros
- Excel VBA Cross Product: Create Cartesian PairsExcel has no built-in worksheet function named CROSSPRODUCT for pairing two lists, but you can create a VBA user-defined function that returns…VBA & macros
- Excel VBA Function Arguments: Syntax and ExamplesIn Excel VBA, function arguments are the values or variables you pass to a function so it can do its work; the…VBA & macros
- Excel VBA Date and Time Formatting: Practical ExamplesTo format a date and time in an Excel cell with VBA, set the cell or range’s NumberFormat property, for example: Range("A2:A20").NumberFormat…VBA & macros
- Excel VBA: Format a Range as a DateTo format a range as dates with Excel VBA, assign a date format to its NumberFormat property, for example Worksheets("Data").Range("B2:B100").NumberFormat = "dd-mmm-yyyy".…VBA & macros
- Excel VBA Format Date Values: Examples and FixesTo format a date in an Excel cell with VBA, set the cell’s NumberFormat property, for example: Range("A1").NumberFormat = "yyyy-mm-dd". This changes…VBA & macros
- Excel VBA Date String Formatting ExplainedIn Excel VBA, use Format$ to turn a date value into a formatted text string, such as Format$(Date, "yyyy-mm-dd"). To change how…VBA & macros
- Excel VBA Date Formatting: Examples and FixesTo format a date in Excel VBA, use Format$ when you need formatted text, or set a cell’s NumberFormat when you want…VBA & macros
- Excel VBA Format Date as DD/MM/YYYY in a WorksheetTo display Excel dates as dd/mm/yyyy with VBA, set the range’s NumberFormat property, for example: Range("B2:B100").NumberFormat = "dd/mm/yyyy". This changes how valid…VBA & macros
- Excel VBA Format Date as dd mm yyyy hh mm ssTo keep a real Excel date/time value, set a cell’s number format with VBA, for example Range("A1").NumberFormat = "dd mm yyyy hh:mm:ss".…VBA & macros
- Excel VBA For Loop: Skip to the Next IterationExcel VBA does not have a built-in Continue For statement. To skip the rest of the current iteration and let the loop…VBA & macros
- Excel VBA: Loop Through Every Sheet in a Workbook SafelyTo run VBA on every worksheet in a workbook, use a For Each loop with the workbook’s Worksheets collection. In a macro…VBA & macros
- Excel VBA For Loop Backwards: Syntax and ExamplesYes. To run an Excel VBA For loop backwards, use For counter = start To finish Step -1; for example, For i…VBA & macros
- Excel VBA For Each Array: How to Loop Through ValuesYes—Excel VBA can use For Each to visit every element in an array. Declare the loop variable as Variant, then write For…VBA & macros
- Excel VBA FLOOR Function: Round Down to a MultipleExcel VBA does not have a built-in function named FLOOR that you can call directly, but you can use Excel’s worksheet function…VBA & macros
- Excel VBA File Last Modified Date: Get It ReliablyIn Excel VBA, use the built-in FileDateTime function to read a file’s last-modified date and time. For the workbook containing the macro,…VBA & macros