+ Reply to Thread
Results 1 to 3 of 3

Press Enter To Run Macro

Hybrid View

  1. #1
    Registered User
    Join Date
    01-18-2013
    Location
    Missouri
    MS-Off Ver
    Excel 2003
    Posts
    2

    Press Enter To Run Macro

    I have been looking around everywhere and can't seem to find what I need. I am working in a workbook with three sheets the first of which I have a macro that using a button searches through the entire workbook and reports the matches below the search. I need this macro to run however on the press of the enter button. So when a string to search for is input in cell B2 then enter is pressed, then the macro runs and the results are reported as they are now.

    Help would be greatly appriciated.

  2. #2
    Forum Contributor ragavan.sridar1's Avatar
    Join Date
    11-19-2012
    Location
    India
    MS-Off Ver
    Excel 2010, Excel 2003
    Posts
    208

    Re: Press Enter To Run Macro

    Hi,

    Try using the private sub workbook function, so that when the data is entered/changed in the cell B2 you can call the macro.

    see if the code given below works for you..

    Private Sub Worksheet_Change(ByVal Target As Range)
    
    If Target.Address = "$B$2" Then
    
    Call your macro
    
    end if
    
    end sub
    Thanks!
    Raga.

    Please,mark your thread [SOLVED] if you received your answer.

    Click the little star * below, to give some Rep if you think an answer deserves it.

    I learnt so many things from these links.

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Press Enter To Run Macro

    Maybe:

    Private Sub Worksheet_Change(ByVal Target As Range)
    Application.OnKey "~", "YOUR MACRO"
    End Sub

+ 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