Syntax

expression.Evaluate(Name)

expression A variable that represents an Application object.

Parameters

Name Required/Optional Data Type Description
Name Required Variant The name of the object, using the naming convention of Microsoft Excel.

Return Value
Variant

Remarks

The following types of names in Microsoft Excel can be used with this method:

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 the code is shorter. The advantage of using Evaluate is that the argument is a string, so you can either construct the string in your code or use a Visual Basic variable.

Example

This example turns on bold formatting in cell A1 on Sheet1.

Visual Basic for Applications
Worksheets("Sheet1").Activate boldCell = "A1" Application.Evaluate(boldCell).Font.Bold = True

See also: