+ Reply to Thread
Results 1 to 4 of 4

How to Create a Search Macro?

  1. #1
    Registered User
    Join Date
    05-22-2013
    Location
    United States
    MS-Off Ver
    Excel 2011 for Mac
    Posts
    4

    How to Create a Search Macro?

    Hey guys,

    So I'm sort of new to all this macro creating business on Excel. Anyways, I have a sheet with Number, First Name, Last Name, Nickname, and Birthday. I need to create some sort of way to search for a specific name so that the sheet will jump to the row in question. If not that, then a pop up window that will say what row the input is in. Any ideas for how to go about this?

    Let me know!

    Thanks,

    Sara

    P.S. I'm using Excel 2011 for Mac

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: How to Create a Search Macro?

    Hi Sara,

    Try this:

    Please Login or Register  to view this content.
    Or This:

    Please Login or Register  to view this content.

    Directions for running the routine(s) just supplied

    Copy the code to the clipboard

    Press ALT + F11 to open the Visual Basic Editor.

    Open a macro-enabled Workbook or save your Workbook As Macro-Enabled

    Select “Module” from the Insert menu

    Type "Option Explicit" then paste the code under it

    With the cursor between Sub and End Sub press F5 (F8 to Single Step)

    OR

    Press ALT + Q to close the code window.

    Press ALT + F8 then double click on the macro name
    Last edited by xladept; 05-22-2013 at 04:21 PM.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Contributor
    Join Date
    10-13-2012
    Location
    Southern California
    MS-Off Ver
    Excel 2007
    Posts
    401

    Re: How to Create a Search Macro?

    Hi Sara,

    If this doesn't work, it's because I no absolutely nothing about the Mac. But the code works on my PC (Excel 2007) and even if it doesn't work, it should give you a few ideas.

    For now, assume your names to be searched are all in the A column.

    In Cell A1, enter the name you wish to search for. Then run this code:

    Please Login or Register  to view this content.
    I specifically tried to make it as short and as simple as possible.

    What it does: It loops through all of the rows, looking at the data (the names) in the A column. With each row it checks to see if the name in that row is the same name as what you entered in Cell a1. If so, it breaks out of the loop and reports the row it found the name in. Otherwise it continues until it comes to the first empty cell in column A.

    Again, it should help to get you started and you can modify it to fit your needs.

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: How to Create a Search Macro?


+ 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