Search notes:

Excel: evaluate expressions on the worksheet

It is possible to evaluate (mathematical) expressions on a worksheet and display the result.
The following example tries to demonstrate how this might be done with Visual Basic for Applications:
option explicit

sub main() ' {

    activeSheet.name = "expressions"

    cells(2,2) = "2+3+4+5"
    cells(3,2) = "22/3"
    cells(4,2) = "sin(3.1)"

    activeSheet.names.add _
       name          := "evalExprToTheRight"             , _
       refersToR1C1  := "=evaluate( expressions!rc[-1])"

    cells(2,3).formulaR1C1 = "=evalExprToTheRight"
    cells(2,3).autoFill                               _
       destination := range(cells(2,3), cells(4,3)) , _
       type        := xlFillCopy

end sub ' }
Github repository about-MS-Office-object-model, path: /Excel/Name/evaluate-expression.bas
After running the program, the worksheet has the following expresssions and results.
This example roughly corresponds to the following GUI manipulations:

See also

The name object.

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/Microsof...', 1758207712, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Microsoft/Office/Excel/Object-Model/Name/evaluate-expression(74): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78