Lesson#146: How to make a simple function in VBA | How to add custom formula in Excel

Lesson#146: How to make a simple function in VBA | How to add custom formula in Excel

Hello Guys! After a long time, I returned with a new lesson. Today I am going to discuss with you how to make a simple function in VBA. The VBA editor opens huge possibilities to make our Excel sheets into a masterpiece. Here we can make functions as per our needs that are not present in our Excel inbuilt functions. No more talking…

Now we start to make a simple function in VBA. The function is to find out the unit weight (Kg/meter) of the reinforcement bar used for construction works.

  • Open the VBA Editor by pressing alt +F11
  • Now insert a module.
  • Now we will write the function in this way.
Function REINWEIGHT(DIA As Variant) As Variant
REINWEIGHT = (DIA * DIA) / 162.2
End Function
  • Now click on Run.
  • Create a function and give a name.

Now the function will look like this and work this way. That is how to make a simple function in VBA.

simple function in VBA
simple function in VBA

Click Here for more posts for VBA and Macro.

See also  Lesson#185: How to make a digital clock with VBA

Hi! I am Puspendu. I am the founder and author of Excelabcd. I am little creative person, blogger and Excel-maniac guy. I hope you enjoy my blog.

Leave a Reply

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

*