+ Reply to Thread
Results 1 to 3 of 3

Key press event, in he formula bar

  1. #1
    Registered User
    Join Date
    01-24-2007
    Posts
    5

    Key press event, in he formula bar

    Hi All,

    can the formula editor bar can receive events? I wanted to see if the user enter a formula, whether I could give hint about the custom functions available.

    Is there any keypress event in Excel? especially to keep track of the formula the user types? (if the user type =S ( for sum), I should be able to get =S in my code. Is this possible? Please let me know. thanks

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Key press event, in he formula bar

    can the formula editor bar can receive events?
    No, it cannot.

    You can use the worksheet_change event to capture the value or formula entered in a cell.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Key press event, in he formula bar

    Hello krish,

    This is an interesting question. Excel does not expose any Formula Bar events through VBA, but it does receive events. The Formula Bar is made up of 2 child windows. The Name Box, which is a ComboBox Class window, and the Formula Bar, which is an Edit Box Class window. The window class names are "ComboBox" and "Excel<", respectively.

    Knowing this information can allow us to construct code to listen in on the messages these windows receive and act accordingly. This requires using using extensive API (Applications Programming Interface) calls. VBA supports the API interface which allows us to access and control low level system operations.

    All in all, it is possible to construct code that would recognize keystrokes in the Formula Bar and know when the "Enter" key had been pressed. The text could then be retrieved, compared, and the appropriate macro called. The drawback here is API code is complex and not user friendly. As I have time, I will work on this. It is a good challenge.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1