An Excel VBA function with two arguments

This article is part of my series: Excel VBA & Macros – A Step by Step Complete Guide.

In this example, I am going to write a VBA function that will calculate the area of a rectangle. We know the area of a rectangle= Length ☓ Width.

A detailed analysis of Excel VBA Function Procedure Arguments

A rectangle.

This is a very simple function. Below shows the code:

Function Area(Length, Width)
    'Finding out the Area of the Rectangle.
    Area = Length * Width
    MsgBox "The Area of your Rectangle is: " & Area
End Function

This function takes two arguments(Length and Width) from the user and shows the area of the rectangle in a message box.

A detailed analysis of Excel VBA Function Procedure Arguments

Showing area of a rectangle in a message box.


Hello! Welcome to my Excel blog! It took me some time to be a fan of Excel. But now I am a die-hard fan of MS Excel. I learn new ways of doing things with Excel and share here. Not only how to guide on Excel, but you will get also topics on Finance, Statistics, Data Analysis, and BI. Stay tuned!

We will be happy to hear your thoughts

      Leave a reply