Lesson#125: How to use function with VBA

Hello we are back again with a very basic VBA learning topic. How to use function with VBA.

Here I am having an array with some random numeric values in the range A1:A10.

I want to make SUM, AVERAGE, MAX, MIN in different cells and I will use VBA for that.

So I have written code like this.

Sub calcu()
Range(“B1”).Value = “SUM”
Range(“B2”).Value = “AVERAGE”
Range(“B3”).Value = “MAX”
Range(“B4”).Value = “MIN”
Range(“C1”).Formula = “=sum(A1:A10)”
Range(“C2”).Formula = “=average(A1:A10)”
Range(“C3”).Formula = “=max(A1:A10)”
Range(“C4”).Formula = “=min(A1:A10)”
End Sub

Now it shows a result like this.

This is how to use function or formula with the use of VBA.

Puspendu is the founder author of Excelabcd. He is a creative person, blogger and Excel-maniac guy.

One comment on “Lesson#125: How to use function with VBA
  1. Cialis says:

    Good answer back in return of this matter with
    solid arguments and explaining all about that.

Leave a Reply

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