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! I am conducting deep dives into the world of Excel. Please join with me and explore Excel deeply. Keep in mind this African proverb: "If you want to go fast, go alone, If you want to go far, go together." Let's together explore Excel deeply! ☕

We will be happy to hear your thoughts

      Leave a reply