VBA Functions

VBA Functions Overview:

VBA Functions are most important which are used while writing procedures or macros. We have list of VBA Functions. These functions are built in functions. We can also write user defined functions as per our requirements. We have different categories of functions. Those are VBA Date and Time Functions, VBA Text/String Functions, VBA Information Functions, VBA Logical Functions, VBA File and Directory Functions, VBA Math and Trig Functions, VBA Financial Functions and VBA Lookup and Reference Functions. Each category has list of functions to deal with different type of data. In this tutorial all functions are explained with syntax and multiple examples.

VBA Functions

Here are the different categories and list of all VBA functions.

VBA Date & Time Functions:

Here are the list of VBA Date and Time Functions.

Function Name Description
VBA DATE VBA Date function returns current system date.
VBA DATEDIFF VBA DateDiff function returns the difference between two date values, based on the interval specified.
VBA DATEPART VBA DatePart function returns a specified part of a supplied date or time
VBA DATESERIAL VBA DateSerial function returns date.
VBA DATEVALUE VBA DateValue function returns the date value for specified string input.
VBA DAY VBA Day function returns day from date.
VBA HOUR VBA Hour function returns hour from time.
VBA MINUTE VBA Minute function returns Minute from time.
VBA MONTH VBA Month function returns month from date.
VBA NOW VBA Now function returns system date and time.
VBA TIME VBA Time function returns current system time.
VBA TIMESERIAL VBA TimeSerialfunction returns time.
VBA TIMEVALUE VBA TimeValue function returns the date value for specified input represents date.
VBA YEAR VBA Year function returns year from date.

VBA Text/String Functions:

Here are the list of VBA Text/String Functions.

Function Name Description
VBA Asc VBA ASC function returns the ASCII value of the first character from a string.
VBA Chr VBA Chr function returns a character of the ASCII value.
VBA Format VBA Format function returns a formatted string from a string expression.
VBA InStr VBA InStr function returns the position of a substring within a string.
VBA InStrRev VBA InStrRev function returns the position of a substring within a string, searching from right to left.
VBA LCase VBA LCase function converts a string to lowercase text.
VBA Left VBA Left function returns the specified number of characters from a given string, starting from the left most character.
VBA Len VBA Len function returns the length of a given string.
VBA LTrim VBA LTrim function removes leading spaces from a given string.
VBA Mid VBA Mid function returns a specified number of characters from a specified string.
VBA Replace VBA Replace function replaces a substring with another string in a given string.
VBA Right VBA Right function returns the specified number of characters from a given string, starting from the right most character.
VBA RTrim VBA RTrim function removes trailing spaces from a given string.
VBA Space VBA Space function returns a string with a specified number of spaces.
VBA Split VBA Split function returns an array of substrings based on a delimiter.
VBA Str VBA Str function returns a string which represents a number.
VBA String VBA String function returns a string which consists of repeated characters.
VBA StrComp VBA StrComp function returns an integer value representing the result of string comparision.
VBA StrConv VBA StrConv function converts a string to a specified format(vbUpperCase, vbLowerCase, vbUnicode, vbWide, vbNarrow, vbProperCase, etc.)
VBA StrReverse VBA StrReverse function reverses a given string.
VBA Trim VBA Trim function removes leading and trailing spaces from a given string.
VBA UCase VBA UCase function converts a string to uppercase text.

VBA Information Functions:

Here are the list of VBA Information Functions.

Function Name Description
VBA ENVIRON VBA ENVIRON function returns value of the current operating system environment variable.
VBA IsArray VBA IsArray function checks a specified variable is an array or not.
VBA IsDate VBA IsDate function checks specified Expression is date or not. It returns True if it is valid date.
VBA IsEmpty VBA IsEmpty function checks specified Expression is empty or not.
VBA IsError VBA IsError function checks specified Expression is error or not.
VBA IsMissing VBA IsMissing function checks specified an optional argument is missing or not.
VBA IsNull VBA IsNull function checks specified Expression is Null or not.
VBA IsNumeric VBA IsNumeric function checks specified Expression is Numeric or not.
VBA IsObject VBA IsObject function checks specified variable is an object or not.

VBA File & Directory Functions:

Here are the list of VBA File & Directory Functions.

Function Name Description
VBA ChDir VBA ChDir function changes the current folder or directory.
VBA ChDrive VBA ChDrive function changes the current drive.
VBA CurDir VBA CurDir function returns the current path.
VBA Dir VBA Dir function returns the first name of a file or directory that matches a pattern.
VBA FileAttr VBA FileAttr function returns the file mode for opened files using the open statement.
VBA FileCopy VBA FileCopy function copies a file from the source directory to the destination directory.
VBA FileDateTime VBA FileDateTime function returns the date and time when a file or directory was created or last modified.
VBA FileLen VBA FileLen function returns the size / length of a file in bytes.
VBA GetAttr VBA GetAttr function returns the attributes of a file or directory.
VBA Kill VBA Kill function deletes a file based on the specified Path Name.
VBA MkDir VBA MkDir function creates a new folder or directory .
VBA Name VBA Name function moves the file to the new directory or folder.
VBA RmDir VBA RmDir function removes an existing directory or folder.
VBA SetAttr VBA SetAttr function sets the attributes of a file or directory.

VBA Data Type Conversion Functions:

Here are the list of VBA Data Type Conversion Functions.

Function Name Description
VBA CBool VBA CBool function converts an expression to a Boolean data type.
VBA CByte VBA CByte function converts an expression to a Byte data type.
VBA CCur VBA CCur function converts an expression to a Currency data type.
VBA CDate VBA CDate function converts an expression to a Date data type.
VBA CDbl VBA CDbl function converts an expression to a Double data type.
VBA CDec VBA CDec function converts an expression to a Decimal data subtype.
VBA CInt VBA CInt function converts an expression to an Integer data type.
VBA CLng VBA CLng function converts an expression to a Long data type.
VBA CSng VBA CSng function converts an expression to a Single data type.
VBA CStr VBA CStr function converts an expression to a String data type.
VBA CVar VBA CVar function converts an expression to a Variant data type.

VBA Logical Functions:

Here are the list of VBA Logical Functions.

Function Name Description
VBA AND VBA AND function returns true, if all the conditions are TRUE.
VBA OR VBA OR function returns TRUE, if any one condition is TRUE.
VBA NOT VBA Not function returns TRUE, if a condition is False. It returns False, if condition is TRUE.

VBA Math(Mathematical) & Trig Functions:

Here are the list of VBA Math(Mathematical) & Trig Functions.

Function Name Description
VBA Abs VBA Abs function converts a value to an absolute number.
VBA Atn VBA Atn function returns the arctangent of a number in radians, not degrees.
VBA Cos VBA Cos function returns the cosine value of an angle in radians.
VBA Exp VBA Exp function returns an exponential value for a specified number.
VBA Fix VBA Fix returns the integer portion of a number.
VBA Int VBA Int function rounds a specified number down to an integer.
VBA Log VBA Log function returns the natural logarithm of a specified number.

Leave a Comment

Your email address will not be published. Required fields are marked *