简体   繁体   中英

How can I calculate the text in one cell as a formula in another cell in microsoft excel?

Here is what I want the Spreadsheet to look like.

       COLUMN A        COLUMN B        COLUMN C        COLUMN D
ROW1   hello           1               hello+hi        10
ROW2   hi              9               hello*hi        9

I want to be able to name the cell B1 after the text in cell A1 and the cell B2 after the text in the cell A2. Then I want to be able to compute the equations in column C and put the answers in column D.

Any help with this would be greatly appreciated.

EVALUATE is available in VBA in all current versions

You can include it in you VBA code, or wrap it into a simple UDF to make it available as a worksheet function

Function ev(r As Range) As Variant
    ev = Evaluate(r.Value)
End Function

It basically treats the value of the passed parameter as an excel formula, same as if it were entered in a cell

"11+5" and "=11+5" will produce the same result

reference: https://superuser.com/questions/253353/excel-function-that-evaluates-a-string-as-if-it-were-a-formula

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM