Thread: Why Evaluate?
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Charles Williams Charles Williams is offline
external usenet poster
 
Posts: 968
Default Why Evaluate?

I use evaluate for 2 reasons.
- to evaluate a Name when you cant be sure what its refersto contains(named
range, dynamic range, named formula etc etc).
- to evaluate an Excel Formula or array formula within VBA without
transferring it to a worksheet, calculating it and reading back the
resulting values.

There are a number of quirks with Evaluate that you should be aware of,
particularly the difference between Application.Evaluate and
Worksheet.Evaluate

see http://www.decisionmodels.com/calcsecretsh.htm for details

Charles
______________________
Decision Models
FastExcel 2.3 now available
Name Manager 4.0 now available
www.DecisionModels.com

"Dave Unger" wrote in message
ups.com...
Hello everyone,

I realize this probably sounds ridiculous, but maybe someone can
explain the purpose of the Evaluate method to me. If I replace the
VBA help examples with the following code, I get the same results:

VBA Help examples

Evaluate("A1").Value = 25
trigVariable = Evaluate("SIN(45)")
Set firstCellInSheet = Workbooks("BOOK1.XLS").Sheets(4).Evaluate("A1")


My Code

Range("A1").Value = 25
trigVariable = Sin(45)
Set firstCellInSheet = Workbooks("BOOK1.XLS").Sheets(4).Range("A1")

Searching the groups turns up numerous examples of using Evaluate, but
I have been unable to figure out "why" use Evaluate. Somewhere, I'm
missing something.

Thank you for your help,

Regards,

DaveU