0

I have small VBA program to calculate area of a rectangle . Using the values in Cell B2 and B3 , i called a function rectangle from sub procedure . I am expecting a area to be calculated in the function and to be returned to the sub procedure . In my case its not happening . Why is that ?

Sub Button1_Click()
    Dim result As Integer
    a = Cells(2, "B").Value
    b = Range("B3").Value
    result = rectangle(a, b)
    MsgBox ("area of rectangle is " & result)
End Sub

Function rectangle(ByVal a As Integer, ByVal b As Integer) As Integer
    Dim area As Integer
    area = a * b
End Function
Community
  • 1
  • 1
ICEMAN
  • 95
  • 2
  • 5

0 Answers0