公式的实时执行
我们可以在不将光标移出单元格的情况下执行公式吗?将数据输入到输入单元格后,我们可以按 Enter 键,也可以从该单元格移出,然后执行与之相关的任何公式。有什么方法可以在输入输入本身时我们可以在 Excel 中看到输出结果吗?请帮助我找到这个选项。
can we execute a formula without moving cursor from the cell? After giving data in to Input cell either we press enter or we move from that cell and then any formula related to that gets executed. Is there any way that while entering input itself we can see the result in output in excel?Please help me in finding this option.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不相信当单元格的“编辑器”拥有焦点和控制权时,代码不可能执行。例如,在编辑公式时尝试在 Excel 中执行其他操作。我相信单元格必须在代码执行之前完成保存其值或公式。
您可以使用公式“监听”单元格何时更新,但这有点复杂。一旦更新,它可能会迫使您返回原始单元格。下面介绍了如何编写一些代码来“侦听”单元格值何时发生变化。在以下示例中:
I1
的值记录到strValue
。I1
的值没有更改,该循环就会保持运行。DoEvents
命令将控制权释放回处理器,这样您就可以在 Excel 运行时使用它。I1
的值发生变化,While
语句将为假并且循环将退出。'
也许,如果您只是想在每次值更改时将控制权返回到原始单元格,则可以使用上面的行而不使用消息框,并在方法执行后返回到循环。请记住,如果您这样做,您可能需要找到另一种方法来退出代码。
为什么要让它在单元格内执行?您的任务的最终目的是什么?
I don't believe it's possible for code to execute while the "editor" of a cell has focus and control. For example, try doing something else in Excel while you are editing a formula. I believe that the cell has to finish saving its value or formula before code can execute.
You can have a formula "listen" for when a cell is updated, but this is a little bit complicated. It could then force you back into the original cell once it is updated. Here's how you can write some code to "listen" for when a value of a cell changes. In the following example:
I1
tostrValue
.I1
has not changed.DoEvents
command releases control back to the processor, which is what allows you to work in Excel while this is running.I1
changes, theWhile
statement will be false and the loop will exit.'
Perhaps if you simply wanted to return control back to the original cell every time the value changed, you could use the line above without the message box and return to the loop once your method executes. Keep in mind that you might have to figure out another way to exit your code if you do that.
Why do you want to have it execute from within the cell? What is the end purpose of your task?
按 F9 进行重新计算,无需离开输入单元格。这适用于 Excel 2007。我不确定早期版本是否有效。
Press F9 to do a re-calc without moving from the input cell. This works in Excel 2007. I'm not sure about earlier versions.