+ Reply to Thread
Results 1 to 13 of 13

Using the Enter key (from a specific cell) to run a macro

  1. #1
    Forum Contributor
    Join Date
    02-12-2012
    Location
    South Africa
    MS-Off Ver
    Excel 2007
    Posts
    275

    Using the Enter key (from a specific cell) to run a macro

    I want to initiate a search macro by pressing the enter key after having entered the value to search

    I don't want to use buttons or forms.

    Is this possible??

    Thanks

  2. #2
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Using the Enter key (from a specific cell) to run a macro

    So you want to run a search every time the enter button is pressed?
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  3. #3
    Forum Contributor
    Join Date
    02-12-2012
    Location
    South Africa
    MS-Off Ver
    Excel 2007
    Posts
    275

    Re: Using the Enter key (from a specific cell) to run a macro

    No just when moving from the single variable cell. the rest of the sheet must operate as normal

  4. #4
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Using the Enter key (from a specific cell) to run a macro

    So which cell or range of cells would you want this to apply to?

  5. #5
    Forum Contributor
    Join Date
    02-12-2012
    Location
    South Africa
    MS-Off Ver
    Excel 2007
    Posts
    275

    Re: Using the Enter key (from a specific cell) to run a macro

    Two separate macro's one initiate from cell D3 and the other from G3

  6. #6
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Using the Enter key (from a specific cell) to run a macro

    Those would be the only 2 cells where you would want a procedure to run after the user presses enter?

  7. #7
    Forum Contributor
    Join Date
    02-12-2012
    Location
    South Africa
    MS-Off Ver
    Excel 2007
    Posts
    275

    Re: Using the Enter key (from a specific cell) to run a macro

    Yes. the rest of the sheet is only for the results.

  8. #8
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Using the Enter key (from a specific cell) to run a macro

    Place the following code in the worksheet module that you want this to occur
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    02-12-2012
    Location
    South Africa
    MS-Off Ver
    Excel 2007
    Posts
    275

    Re: Using the Enter key (from a specific cell) to run a macro

    The code is doing something good I just need to adjust the macros to work. will post the solution once I have it.

    Thanks

  10. #10
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Using the Enter key (from a specific cell) to run a macro

    Please keep us informed.

  11. #11
    Forum Contributor
    Join Date
    02-12-2012
    Location
    South Africa
    MS-Off Ver
    Excel 2007
    Posts
    275

    Thumbs up Solved: Using the Enter key (from a specific cell) to run a macro

    Here is the working solution


    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim FoundRng1 As Range

    Application.EnableEvents = False
    If Target.Address = "$D$3" Or Target.Address = "$G$3" Then
    ' Second macro is named Message1
    Message1
    End If
    Application.EnableEvents = True
    End Sub


    and this is place on the VB sheet and not the module.

    Within my macro I use an "IF" to rout between two.

    Thanks

  12. #12
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Using the Enter key (from a specific cell) to run a macro

    Hi evertjvr,

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

  13. #13
    Forum Contributor
    Join Date
    02-12-2012
    Location
    South Africa
    MS-Off Ver
    Excel 2007
    Posts
    275

    Thumbs up Solved: Using the Enter key (from a specific cell) to run a macro

    Here is the working solution

    Please Login or Register  to view this content.
    and this is place on the VB sheet and not the module.

    Within my macro I use an "IF" to rout between two.

    Thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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