Exit a cell when entering data
ThomasMexcel
Posted messages
28
Registration date
Status
Member
Last intervention
-
yves -
yves -
Hello, by pressing F2, it is possible to "enter" a cell to insert text. Then, if you press Escape, you can "exit" the cell without validating the text.
I have an Excel file on which I run several macros. When I am still entering text in a cell, if I change files, an error message appears because the macros can no longer run.
The question is then the following: how can it be possible to "exit" the cell with a VBA command, so I can navigate freely between my different files?
I hope I have been clear enough..
Thank you in advance for your help, have a good day.
I have an Excel file on which I run several macros. When I am still entering text in a cell, if I change files, an error message appears because the macros can no longer run.
The question is then the following: how can it be possible to "exit" the cell with a VBA command, so I can navigate freely between my different files?
I hope I have been clear enough..
Thank you in advance for your help, have a good day.
1 answer
-
Hello Thomas,
Try using this VBA instruction:
SendKeys "{ESC}", True
It's to simulate a press of the ESC key with VBA;
with True, the macro waits for the key to be processed before
continuing its execution; check the VBA help for more
details on the SendKeys instruction.
Best regards
-
Hello Yves,
Indeed, the proposed order could be a solution.
However, I can't determine the equivalent VBA condition for: if I am in input mode in a specific range of cells for more than 1 second, then SendKeys Escape." I suppose I have to allow some time during which I permit input; otherwise, I'll get stuck..- According to the VBA help for the SendKeys instruction, the 2nd parameter allows you to wait
or not for the processing of the sent key sequence (here "{ESC}"), but it does not
allow for a finer configuration like the one you want: there is no 3rd
parameter for a delay (one second or otherwise); I don’t have any other solution
to offer you; perhaps another participant will have an idea?
-