Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 4 of 4

Thread: Execute code from a textbox by pressing Enter. Textbox is em

  1. #1
    New Member
    Join Date
    May 2002
    Location
    Stan
    Posts
    11
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I would like to press enter within a text box and have code execute. The textbox is inserted into Sheet1. Not on a user form.

    Currently, I enter the text in a textbox and pressing enter does nothing. I placed a button next to the textbox and click it to execute the code. I think this should be simple, but I can't figure it out... Thanks, Stan.

    [ This Message was edited by: Tanner on 2002-05-10 08:47 ]

  2. #2
    Board Regular
    Join Date
    Mar 2002
    Location
    Cincinnati, Ohio, USA
    Posts
    6,824
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Is your textbox on a userform or a worksheet?
    Tom

  3. #3
    MrExcel MVP
    Colo's Avatar
    Join Date
    Mar 2002
    Location
    Kobe, Japan
    Posts
    1,456
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    2 Thread(s)

    Default

    Hi Tanner,
    Assuming it is on an userform.
    Why don't you use keydown event. Here is sample for you.



    Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    If KeyCode = 13 Then Call YourMacro
    End Sub

    Private Sub YourMacro()
    MsgBox "it works!"
    End Sub


    Hope this helps + pen pineapple apple pen!

    Masaru Kaji aka Colo - cellmasters.net

  4. #4
    New Member
    Join Date
    May 2002
    Location
    Stan
    Posts
    11
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Thanks for the Solution, Colo. Your solution worked even though the textbox is embedded into sheet 1 and not on a user form.

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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