+ Reply to Thread
Results 1 to 8 of 8

Creating Search Macro

  1. #1
    Registered User
    Join Date
    07-13-2009
    Location
    Fairfax, Virginia
    MS-Off Ver
    Excel 2003
    Posts
    4

    Creating Search Macro

    Hi,

    I am writing a macro to search the range A1:A70 on all worksheets in a workbook. The macro will pull up an input box for a user to type in a part number and should find the location of the part number in its corresponding worksheet.

    The code I have so far looks like this...
    --
    Please Login or Register  to view this content.
    --

    Does any of this look correct at all? I'd really appreciate the help. Thanks.
    Last edited by vtmickster; 07-13-2009 at 10:23 AM. Reason: Code wrapped

  2. #2
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: Creating Search Macro

    You need to edit your post and put code tags around the code before anyone will be allowed to comment on it.
    To do that select [Edit] -> [Go Advanced], then select your code, and click the [Code] button.
    If you find the response helpful please click the scales in the blue bar above and rate it
    If you don't like the response, don't bother with the scales, they are not for you

  3. #3
    Registered User
    Join Date
    07-13-2009
    Location
    Fairfax, Virginia
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Creating Search Macro

    Did that change it?? Thanks. Clearly, I'm new here

  4. #4
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: Creating Search Macro

    Yes that fixed it

    The code looks 'ok', I'm guessing it is from an example found elsewhere?
    Is the partnumber the only thing in the cell where it is located, or is there other text in the same cell?
    Will there only ever be one match of the partnumber?
    If there are multiple matches possible, then do you just want the first one presented?
    Once the macro has found the part number in the sheet what is it to do with it? (A message box, or are you doing further processing in your macro based on it?)

  5. #5
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Creating Search Macro

    So what do you want the macro to return?

    The sheet/address of every cell where it finds the search value? Can it be found more than once?

  6. #6
    Registered User
    Join Date
    07-13-2009
    Location
    Fairfax, Virginia
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Creating Search Macro

    I would prefer it to bring the user to the corresponding location, but if this is not feasible, returning the cell address would be appropriate. The code is part of an example found elsewhere but I've modified a little bit.

    The part number is the only thing located in the cell and there would most likely not be multiples. In the event of multiple matches, the first should be presented.

    Thanks for your help!
    Last edited by vtmickster; 07-13-2009 at 11:21 AM.

  7. #7
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: Creating Search Macro

    This should do what you want:

    Please Login or Register  to view this content.
    If you have any questions please do ask

  8. #8
    Registered User
    Join Date
    07-13-2009
    Location
    Fairfax, Virginia
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Creating Search Macro

    This absolutely helped. Thanks, Phil_V!

+ 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