VBA Functions

Browse the functions by category. Use wildcards in search: * and ?.

Array / Information

Variant array from arguments.

Filter strings in an array.

True if variable is array.

True if expression is date.

True if variable uninitialized.

True if expression is error value.

True if optional Variant not supplied.

True if expression is Null.

True if expression numeric.

True if expression is object.

Lower bound of array dimension.

String describing data type.

Upper bound of array dimension.

Subtype of a variable.

Color / Misc

Choice by index.

Immediate If.

QB 16-color palette value.

RGB color value.

Returns first True expression's value.

Conversion

ASCII code of first character.

Character for code.

Converts an expression to the specified data type.

Format an expression.

Hexadecimal string of a number.

Octal string of a number.

String of a number (leading space for positive).

Converts string to number.

Date & Time

Current system date.

Add time interval to a date.

Difference between dates.

Specified part of date.

Date from year, month, day.

String to date.

Day of month.

Hour (0–23).

Minute (0–59).

Month number (1–12).

Month name.

Current date/time.

Seconds (0–59).

Current time.

Seconds since midnight.

Time from parts.

String to time.

Day of week (1–7).

Weekday name.

Four-digit year.

DDB

Returns a Double specifying the depreciation of an asset for a specific time period by using the double-declining balance method or some other method you specify.

File / I-O & Environment

Creates and returns a reference to an ActiveX object.

Current path.

File/folder name matching a pattern; iterate with subsequent Dir calls.

Environment variable value.

End-of-file state for open file.

Returns information about a file opened with the Open statement — such as file access mode or file type.

File last modified date/time.

File length in bytes.

Next available file number.

Returns a two-dimensional array containing all key settings saved in the Windows Registry under a specified app and section.

Returns attribute information (such as Read-Only, Hidden, System) for a file or folder.

Returns a reference to an existing OLE Automation object (for example, an Excel workbook or Word document already running).

Retrieves a key value from the Windows Registry for a specified application, section, and key.

Prompt dialog that returns user input.

Current position within open file.

Length of open file in bytes.

(Classic Mac only, obsolete) Returns a four-character identifier for a Macintosh file type.

(Mac only, deprecated) Executes an AppleScript script from within VBA and returns the result.

Message box; returns which button was clicked.

Get/Set file position.

Run an executable; returns task ID.

Financial

Returns the future value of an annuity or investment, based on periodic, constant payments and a constant interest rate.

Returns the interest payment for a given period of an annuity, based on periodic, constant payments and a constant interest rate.

Returns the internal rate of return for a series of periodic cash flows (payments and receipts).

Returns the modified internal rate of return for a series of cash flows, considering both the cost of investment and the interest received on reinvestment.

Returns the number of periods for an annuity, based on periodic, constant payments and a constant interest rate.

Returns the net present value of an investment, based on a discount rate and a series of future cash flows.

Returns the payment amount for an annuity, based on constant payments and a constant interest rate.

Returns the principal payment for a given period of an annuity, based on periodic, constant payments and a constant interest rate.

Returns the present value of an annuity or investment, based on constant payments and a constant interest rate.

Returns the interest rate per period of an annuity, given the number of periods, payment amount, present value, and (optionally) future value.

Returns the straight-line depreciation of an asset for a single period.

Returns the sum-of-years-digits depreciation of an asset for a specified period.

Formatting / Conversion

Format as currency.

Format as date/time.

Format as number.

Format as percent.

Math

Returns the absolute value of a number.

Arctangent of a number in radians.

Cosine of an angle (radians).

The following is a list of nonintrinsic math functions that can be derived from the intrinsic math functions.

e raised to a power.

Returns the integer portion of a number.

Natural logarithm.

Indicates where a number falls in ranges.

Pseudo-random number.

Rounds using banker’s rounding.

Sign of a number (-1,0,1).

Sine (radians).

Square root.

Tangent (radians).

Program Flow / Interaction

Executes a method of an object, or sets or returns a property of an object.

Returns the argument portion of the command line used to launch Microsoft Visual Basic or an executable program developed with Visual Basic. The Visual Basic Command function is available in Microsoft Access, but not in other Microsoft Office applications.

Yields execution so the operating system can process other events (like keystrokes, mouse clicks, repaint requests) before resuming code.

Returns or generates a runtime error. Can also be used to supply a custom error message corresponding to an error number.

Returns the current status of the Input Method Editor (IME), used for East Asian character input.

Returns a specified number of characters from an open sequential file.

Used with Print statements to position output at a specific column number.

String / Text

Position of substring.

Reverse search.

Join array to string.

Lowercase.

Leftmost characters.

Length of string/bytes in variable.

LTrim removes leading spaces, RTrim removes trailing spaces, and Trim removes both leading and trailing spaces from a string.

Substring.

Replace substring.

Rightmost characters.

Spaces string.

Returns a string consisting of a specified number of space characters.

Split into array.

String compare.

String conversions (e.g., proper case).

Repeating character string.

Returns a string in which the character order of a specified string is reversed.

Uppercase.

Type Conversion

Each function coerces an expression to a specific data type.

No functions match your search.