Forum Discussion

AbdelhakimMoM's avatar
AbdelhakimMoM
Copper Contributor
Aug 31, 2023

is there any way to use the cell function in vba macros

Hi Everyone!

 

i hope you're all doing okay.

 

i guess my issue is there in the title waiting for an answer.

i want to use the cell function but couldn't find it or use through application.worksheetfunction

 

thanks

1 Reply

  • AbdelhakimMoM 

    Let's say you want to calculate the sum of A2:A5 on Sheet1.

     

    Dim s As Double

    s = Application.WorksheetFunction.Sum(Worksheets("Sheet1").Range("A2:A5"))

     

    Another way would be

     

    Dim s As Double

    s = Evaluate("SUM(Sheet1!A2:A5)")

     

    or even

     

    Dim s As Double

    s = [SUM(A2:A5)]

Resources