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.
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:
- I record the value of Cell
I1
tostrValue
. - Then I run a loop that stays running as long as the value of cell
I1
has not changed. - The
DoEvents
command releases control back to the processor, which is what allows you to work in Excel while this is running. - Once the value of cell
I1
changes, theWhile
statement will be false and the loop will exit. - After the loop exits, a message box pops up that tells you the value changed and then the original cell is selected again.
'
Sub testChange()
Dim strValue As String
strValue = Range("I1").Value
Do While strValue = Range("I1").Value
DoEvents
Loop
MsgBox "The value changed!"
Range("I1").Activate
End Sub
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?
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.