Detect If Cell Is In 'editing' Mode

  • Hi,
    I'm doing the vba programming for excel where I added a button to the excel, and when user click on the button, it will trigger my function.


    My question is: if currently there is a cell been focused, how can I know whether that is in the 'editing mode' (ie, focus on that cell and double click on that) or merely 'focus' on that cell? Any of the excel object property for this?


    Thanks in advance.

  • Re: Detect If Cell Is In 'editing' Mode


    Yes, as the 'behaviour' is different when we program for it. 'Editing' mode can cause error if we do not handle properly.


    A further question might be: if we have detected it is in 'editing' mode, how can set it back to 'focus' mode through the vba macro?


    Thanks

  • Re: Detect If Cell Is In 'editing' Mode


    Quote from mkgan

    Hi,
    I'm doing the vba programming for excel where I added a button to the excel, and when user click on the button, it will trigger my function.


    My question is: if currently there is a cell been focused, how can I know whether that is in the 'editing mode' (ie, focus on that cell and double click on that) or merely 'focus' on that cell? Any of the excel object property for this?


    Thanks in advance.


    Pushing the Button will give NO effect if one of cells is in 'editing mode'.

  • Re: Detect If Cell Is In 'editing' Mode


    What do you want to do ith the cell, generally you don't need to select or activatea cell to work with it in VBA. To be honest I'm not even sure what you mean by "editing mode", do you mean Locked?

  • Re: Detect If Cell Is In 'editing' Mode


    Quote from mkgan

    Hi,
    pushing the button will give no different. but there are difference when you calling/changing the excel application's properties, etc.


    So any clue please!


    I'll try to explain - when macros is running, there are no cells in 'editing mode'. - There's nothing to detect.
    Can you give an example?

  • Re: Detect If Cell Is In 'editing' Mode


    Quote from mkgan

    Example:


    I call the following function. and this cause an error when the cell is in 'editing' mode:


    appExcel.DisplayAlerts = False


    And what must happen if error occurs? Can you use

    Code
    On Error Goto errHndl
    'some code
    errHndl:
    'code if error


    or

    Code
    On Error Resume Next
    appExcel.DisplayAlerts = False
    If Err then
    'code if error
    End if


    And most interesting question: How you execute macros, when cell is in 'editing mode'. Where this macros is? Is it in another Workbook?

  • Re: Detect If Cell Is In 'editing' Mode


    I suggest that you read the Forum Rules that you agreed to. You neglected to use Code tags despite being reminded on the page from which you asked this question.


    I have added them this time, but future posts may well be deleted for non-compliance with the Rules

  • Re: Detect If Cell Is In 'editing' Mode


    Sorry for the mistake (code tags) I made.


    Using error handling doesn't really helps for me. I need to know exactly if it is in the 'editing' mode. I am not sure 'editing' mode is the right term as I cannot find any relevant properties/routines of the excel application or cell objects. I feel 'editing' mode is make sense as it is when we double click on the cell and going to edit the cell.


    The event below is triggered when I click on the button.


    Code
    Private Sub MyButton_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean)
  • Re: Detect If Cell Is In 'editing' Mode


    It would save a lot of time if you explained xactly what you are doing, probably post your code.You are definitely using VBA & not VB aren't you.


    You don't double click a cell to edit it.
    you have only shown us that you are using a Commandbutton, no actual code.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!