Saturday, March 31, 2007

Using Excel Functions in VBA

Excel has several useful functions, which can be implemented in VBA code using the Evaluate Method

Evaluate Method converts a Microsoft Excel name to an object or a value

For example , the following method adds the values of the cells A1 to A6.

Sub Evaluate_Usage()

Dim lSum As Long

lSum = Evaluate("=SUM(A1:A6)")

End Sub

USe of evaluate has reduced a roundabout way of looping thru the cells and summing it up.

What next.. use the sum if, count if functions and evaluate!!!

No comments:

Post a Comment

Share on Facebook
Related Posts Plugin for WordPress, Blogger...

Visual Basic for Applications (VBA) Forum (recent threads)

CodeKeep VBA Feed

Visual Studio Tools for Office Forum (recent threads)

Download Windows Live Toolbar and personalize your Web experience! Add custom buttons to get the information you care about most.

Office Business Applications (OBA) Team Blog

MSDN Code Gallery Published Resources For Tag VSTO Google Group