excel - Mathematical formula evaluation in Excel
问题描述
I want to evaluate a mathematical function existing in some cell in Microsoft Excel with some value from other cell, let say that in the A1 cell the user writes “X^2+2X+5” and in the cell A2 writes 3, I want to obtain the result on A3 equals to 20 (the function evaluation for X=3). The idea is writing a macro that has two parameters, the first one, the expression and the other the variable value. Where can I find the code (VB Excel Macro) for doing this without starting from zero? Thanks.
解决方案
您可以使用Application.Evaluate
,例如
application.Evaluate(replace([A1],"X",[A2]))
您必须将公式更新为X^2+2*X+5
推荐阅读
- string - String.Split 到 DataRow 或 DataTable.Row.Add
- python - 为什么我的 for 循环覆盖变量而不是追加?
- php - 不能在不同设备/浏览器上同时登录同一个账号
- c++ - 为什么在 GLFW 窗口中使用此代码在我的屏幕上没有绘制立方体?
- amazon-web-services - Terraform 0.12.13 - 无法旋转 AWS 实例
- javascript - 如何在 Vue 的 iframe 中渲染子组件?
- node.js - 通过 Cloud Storage 触发的通过 Cloud Functions 下载的文件是否有大小限制?
- sql - 有什么方法可以将 API 响应作为文件保存到本地计算机磁盘
- python - epoch 内的平均误差和误差标准差未正确更新 - PyTorch
- mongodb - 为什么在将 GZipped 存档文件 (.agz) 导入 Studio 3T 后收到“连接到数据库服务器时出错:无法访问服务器”?