Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Evaluate string 1

Status
Not open for further replies.

mloew

Automotive
Apr 3, 2002
1,073
Does anyone know how to have Excel evaluate the commands in a string? For example:

Cell A6 contains a numerical value.
Cell B6 contains the string "=A6*2"

I would like to have a cell that can convert the command in B6. In Matlab the command would be eval(string). Obviosly I am looking for a general solution to solve for any string.

Searching the Excel help files and some Googling only leads me to beleive that I need some VBA code. Can anyone help?

Thanks in advance.


Best regards,

Matthew Ian Loew


Please see FAQ731-376 for tips on how to make the best use of Eng-Tips Fora.
 
Replies continue below

Recommended for you

Hello!

try:

SUB Q()
[C6].Formula=[B6].Text
END SUB

HTH

_LF
 
You may use the following VB function - put it in a module in your workbook, and call it as =Eval(B6) in your example.
Code:
Function Eval(S As String)
    Eval = Evaluate(S)
End Function

Cheers,
Joerd

Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor