• Skip to main content
  • Skip to primary sidebar
  • Skip to footer

Microsoft Excel Tips and Tricks - Computergaga

  • Home
  • Excel Online Courses
  • Excel Functions List
  • Free Downloads
  • Blog
  • Tutorials
  • About
Home / VBA / Excel VBA Evaluate Function – How to use this Secret VBA Function

Excel VBA Evaluate Function – How to use this Secret VBA Function

The Evaluate function is a hidden secret that few Excel VBA users know. In this blog post, we will explore what it does, and why you will be happy to know it.

The Excel VBA Evaluate Function converts a Microsoft Excel name to an object or a value.

The syntax for the Evaluate function looks like this;

Evaluate(Name)

The name can be a formula or the name of an object that you want to evaluate. This name must not exceed 255 characters.

What does this mean? And why is this useful?

Well let’s have a look at some typical uses of the Evaluate Function.

Watch the Video – Excel VBA Evaluate Function

The most common use of Evaluate is to simplify using worksheet formulas in VBA.

In this example, the worksheet function Sum has been used to total column A.

Dim Total as Long
Total = Application.Sum(Range("A:A"))

But it can be simplified to this.

Dim Total as Long
Total = Evaluate("Sum(A:A)")

When writing the formula in the Evaluate function, you do not need to type the equals sign, and it must be enclosed in inverted commas ” “.

If references to worksheets are required, then the code can be shortened even more impressively.
Compare this;

Worksheets("Sheet1").Range("A2").Value * Worksheets("Sheet2").Range("A2").Value

To this;

Evaluate("Sheet1!A2*Sheet2!A2")

You can also write the Evaluate function in shorthand by using square brackets instead of the word Evaluate, parenthesis and inverted commas.

For example a formula could be written like this;

[Sum(A:A)]

Evaluate is Not Limited to Just Formulas

Instead of using the Range object to select a range, you could use the Evaluate shorthand.

So this;

Range("A2").Select

Could be this;

[A2].Select

The Excel VBA Evaluate function certainly does have some impressive uses and can simplify your code very quickly.

It is worth exploring what else this function is capable and see how it could benefit you.

More Excel VBA Tutorials

  • 6 ways to find the last row in a list
  • 5 examples of why and how to use the Immediate Window
  • Automatically refresh a PivotTable with VBA
  • Export all worksheets to PDF

Related Posts:

  • Moving average in Excel thumbnail
    Moving Average in Excel
  • Live currency exchange rate in Excel thumbnail
    LIVE Currency Exchange Rate in Excel
  • Sum formulas only in Excel
    Sum Formulas Only in Excel
  • SWITCH function feature
    Excel SWITCH Function - Nested IF Function Alternative

Reader Interactions

Comments

  1. Ong Chin Hooi says

    15 January 2018 at 5:30 pm

    Woo! that was good make more of these, please.
    Thanks.

    Reply
  2. No Thanks says

    9 June 2021 at 11:52 pm

    “Inverted commas”? Seriously?? Last I heard, those were called “quotation marks”, “double quotes”, or just “quotes”. Aside from that, it’s a good (though a bit shallow) article.

    Reply
    • Alan Murray says

      26 July 2021 at 9:13 pm

      Yes, they go by all of those names and some are specific on region.

      Reply

Leave a Reply Cancel reply

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

Primary Sidebar

Recent Posts

  • Excel SWITCH Function – Nested IF Function Alternative
  • Sum Formulas Only in Excel
  • How to Calculate Age in Excel
  • Custom Sort in Excel
  • Case Sensitive Lookup with XLOOKUP in Excel
Advanced Excel Success book

Footer

Contact

[email protected]

LinkedIn Twitter YouTube

Useful Links

  • Home
  • Excel Online Courses
  • Tutorials
  • Sitemap
  • Privacy Policy
  • Jobs by Jooble

Course Topics

  • Blog
  • Charts
  • Courses
  • Dashboards
  • Downloads
  • Excel Tips
  • Formulas
  • Mail Merge
  • Office
  • PivotTables
  • Power BI
  • Power Pivot
  • Power Query
  • VBA

Join Our Mailing List

© Copyright 2009 Computergaga · All Rights Reserved ·