30 Advanced Excel Tips for 2026

Excel Champs / VBA / Top VBA Functions
By Puneet Gogia (Microsoft MVP)

Top VBA Functions

30+ Advanced Excel Tips for 2026

No spam. Only Excel Stuff. God Promise. 😊

Call VBA’s built-in functions by name in your code, with their arguments in brackets: x = Len(Range("A1").Value) returns the number of characters in A1. They work on the values you pass them, not on cells directly, so read the cell’s value first.

The ones used most, by group:

<ul>
<li>Text: Left, Right, Mid, Len, InStr, Replace, Trim, UCase, Split.</li>
<li>Dates: Date, Now, DateAdd, DateDiff, DateSerial, Format.</li>
<li>Numbers: Round, Int, Abs.</li>
<li>Checks: IsEmpty, IsNumeric, IsDate, IsError.</li>
<li>Arrays: UBound, LBound, Join, Filter.</li>
</ul>

To convert between types, use the C functions: CStr for text, CLng for whole numbers, CDbl for decimals, CDate for dates and CBool for True/False. Val("12abc") returns 12, because it reads digits until the first character that can’t be part of a number.

Worksheet functions that VBA doesn’t have, such as VLookup, SumIfs and CountIf, are called through WorksheetFunction, as in WorksheetFunction.SumIfs(...). To write your own function, create a Function procedure in a standard module.

VBA’s Round rounds halves to the nearest even number, so Round(2.5, 0) returns 2 and Round(3.5, 0) returns 4. For the rounding Excel uses in cells, call WorksheetFunction.Round(2.5, 0), which returns 3.

Once you get started with VBA, learning how to use the built-in functions while writing VBA code is the next important step.

In VBA, built-in functions are predefined procedures or methods that can be used to perform specific tasks. These functions are part of the VBA library and can simplify programming by providing standard functionality without requiring you to write the code from scratch.

Here I have listed the most useful VBA functions (category-wise), and most of them link to a detailed guide with examples and sample codes.

These functions are listed under six categories to help you understand the purpose of each function easily.

Below is the list of categories of the major VBA functions. All the functions are further listed under these categories:

VBA TEXT (String) Functions

VBA TEXT functions help you manipulate text value(s) from a cell, a range of cells, or an entire worksheet or workbook.

In simple words, these functions are specifically built to change text values. Below, we have a list of some of the most important functions that you can learn to use:

Apart from these, InStrRev (finds text from the end), StrComp (compares two strings), StrConv (converts to proper case and more), Split (splits text into an array), Format (formats a number or date as text), and Chr and Asc (convert between a character and its code) are text functions that you’ll use often.

Here’s a simple example where Trim removes the extra spaces from the text, UCase converts it to upper case, and Len counts the characters:

Sub TextFunctions()
Dim myText As String
myText = " excel champs "
MsgBox UCase(Trim(myText))
MsgBox Len(Trim(myText))
End Sub

The first message box shows “EXCEL CHAMPS” and the second shows 12.

VBA DATE & Time Functions

VBA DATE & Time functions are specifically built to deal with dates and times in your data.

With these functions, you can extract part of a date, add or subtract days from a date, get the difference between two dates, add hours, minutes, and seconds to a time, and calculate the difference between two time values.

Below, we have a list of date functions that you can learn to use:

A few more date and time functions that you’ll need: DateDiff (the difference between two dates in days, months, years and more), Year, Day, Hour, Minute and Second (extract a part of a date or time), Time (the current time), TimeSerial (builds a time from hours, minutes and seconds), and Timer (the seconds passed since midnight, useful to time your code).

In the code below, the first message box shows the date one month from today, and the second shows the number of days from 1 January 2026 to today:

Sub DateFunctions()
MsgBox DateAdd("m", 1, Date)
MsgBox DateDiff("d", DateSerial(2026, 1, 1), Date)
End Sub

VBA MATHS Functions

VBA MATHS functions are designed to perform specific mathematical calculations. In simple words, these functions do calculations that would otherwise take several lines of code.

Below, we have a list of maths functions that you can learn to use:

Other maths functions in VBA are Exp, Log (the natural logarithm), Sgn (the sign of a number), Rnd (a random number between 0 and 1) and Atn, Sin, Cos and Tan for trigonometry.

Note: VBA ROUND uses banker’s rounding, so a number that ends in 5 is rounded to the nearest even number. Round(2.5) gives 2 and Round(3.5) gives 4, while the worksheet ROUND function gives 3 and 4. If you need the worksheet result, use WorksheetFunction.Round instead.

VBA Information Functions

VBA information functions can return information about a variable or expression’s data type or value. Here are some commonly used information functions in VBA:

You’ll also use IsDate, IsNumeric, IsEmpty, IsNull and IsObject to test a value before you use it, and TypeName and VarType to find out the data type of a variable. For example, IsNumeric(Range(“A1”).Value) returns True if cell A1 has a number, so you can check the value before you do a calculation with it.

VBA ARRAY Functions

You can use VBA Array functions to work with arrays, which are collections of elements of the same type. These functions help you to manipulate arrays efficiently. Here are some commonly used VBA array functions:

VBA Data Type Conversion Functions

In VBA, data type conversion functions convert data from one type to another. These functions are helpful when you need to ensure that your variables are of the correct type for your operations. Here are some commonly used data type conversion functions in VBA:

Each of them takes a value and returns it as the data type in its name:

  • CStr: Converts a value to a String.
  • CInt and CLng: Convert a value to an Integer or a Long (whole numbers). They round a .5 to the nearest even number, like Round.
  • CDbl: Converts a value to a Double (a number with decimals).
  • CDate: Converts text that looks like a date to a Date.
  • CBool: Converts a value to True or False.
  • Val: Reads the number at the start of a text, so Val(“12abc”) returns 12.

If the value can’t be converted (like CInt(“abc”)), you get a Type mismatch error, so check it first with IsNumeric or IsDate.

How to Use a VBA Function in Your Code

You use a VBA function by typing its name, followed by its arguments in parentheses, and you can use the result in a variable, a cell or a message box. When you type the name and the opening parenthesis, the VB Editor shows you the arguments the function takes.

And if you want to see all the functions, type VBA followed by a dot in your code, and the editor lists every function from the VBA library. You can also press F2 to open the Object Browser and select “VBA” from the library list.

Use Excel Worksheet Functions in VBA

VBA doesn’t have every function that you have in Excel, like SUM, MAX, COUNTIF or VLOOKUP. But you can use these worksheet functions in your code with WorksheetFunction:

Sub UseWorksheetFunction()
MsgBox WorksheetFunction.Sum(Range("A1:A10"))
MsgBox WorksheetFunction.Max(Range("A1:A10"))
End Sub

When a function has the same name in VBA and in Excel (like Round or Trim), the VBA one is used unless you write WorksheetFunction before it, and the two can give different results.

Create Your Own Function (UDF)

When there’s no built-in function for what you need, you can write your own with a Function procedure. Insert a standard module (Insert ➤ Module) in the VB Editor and add the code below. This function adds a tax rate to an amount:

Function AddTax(Amount As Double, Rate As Double) As Double
AddTax = Amount * (1 + Rate)
End Function

Now you can use it in your code, or in a worksheet cell like any other function:

=AddTax(A1,0.18)

A function that you want to use in a cell needs to be in a standard module, not in a sheet module or the ThisWorkbook module, and you need to save the file as a macro-enabled workbook (.xlsm).

Frequently Asked Questions

What Is the Difference Between a VBA Function and a Worksheet Function?

A VBA function (like UCase or DateAdd) is part of the VBA language and works only in your code. A worksheet function (like SUM or VLOOKUP) is part of Excel, and you can use it in a cell or in your code with WorksheetFunction.

Can I Use a VBA Function in a Worksheet Cell?

Not directly. You need to wrap it in your own Function procedure (a UDF) in a standard module, and then use that function in the cell.

Why Does VBA Round Give a Different Result Than Excel’s ROUND?

VBA’s Round uses banker’s rounding and rounds a .5 to the nearest even number, so Round(2.5) returns 2. Excel’s ROUND always rounds a .5 away from zero and returns 3. Use WorksheetFunction.Round in your code when you need the same result as the worksheet.

Puneet Gogia

Written by

Puneet Gogia

Microsoft MVP — Excel · Founder, Excel Champs

Twelve years of teaching Excel, and a decade before that using it as a data analyst. Every tutorial here is written from a file I actually built.

3M+ readers helped
1,000+ tutorials written
Since 2015 teaching Excel

Leave a Comment