Applies To
Application Object, Chart Object, DialogSheet Object, Worksheet Object.
Description
Converts a Microsoft Excel name to an object or to a value.
Syntax
object.Evaluate(name)
object
Optional for Application, required for Chart, DialogSheet, and Worksheet. Contains the named object.
name
Required. The name of the object, using the naming convention of Microsoft Excel.
Remarks
The following names in Microsoft Excel may be used with this method:
A1-style references. Any reference to a single cell using A1 notation. All references are considered to be absolute references.
Ranges. You may use the range, intersect, and union operators (colon, space, and comma) with references.
Defined names in the language of the macro.
External references using the ! operator. These references could be to a cell or a name defined in another workbook, for example, Evaluate("[BOOK1.XLS]Sheet1!A1").
Graphic objects using their Microsoft Excel name ("Oval 3", for example). You cannot use the number alone.
Note
Using square brackets (for example, "[A1:C5]") is identical to calling the Evaluate method with a string argument. For example, the following expression pairs are equivalent.
[a1].Value = 25 Evaluate("A1").Value = 25 trigVariable = [SIN(45)] trigVariable = Evaluate("SIN(45)") Set firstCellInSheet = Workbooks("BOOK1.XLS").Sheets(4).[A1] Set firstCellInSheet = Workbooks("BOOK1.XLS").Sheets(4).Evaluate("A1")
The advantage of using square brackets is that it is shorter. The advantage of using Evaluate is that the argument is a string, so you can construct the string in your code or use a Visual Basic variable.
Example
This example turns on bold formatting in cell A1 on Sheet1.
Worksheets("Sheet1").Activate boldCell = "A1" Application.Evaluate(boldCell).Font.Bold = True