+ Reply to Thread
Results 1 to 2 of 2

Modifying macro to search for string instead of matching value.

  1. #1
    Registered User
    Join Date
    09-16-2010
    Location
    Glasgow
    MS-Off Ver
    2010
    Posts
    68

    Modifying macro to search for string instead of matching value.

    Hi everyone,

    I have a spreadsheet with 2 worksheets:
    - Worksheet 1 is named Inventory
    - Worksheet 2 is named Addresses

    The Inventory worksheet contains 2 columns, ie:
    - column 1 (named Hostname) is a list of names
    - column 2 (named SN) is a list of serial number

    The Addresses also contains 2 worksheet, ie:
    - column 1 (named SN) is a list of serial number
    - column 2 (named Address) is a list of addresses

    I am using the macro below (which I kindly got from stanleydgromjr) to match the Serial Number from column 2 of the Inventory worksheet to column 1 of the Addresses worksheet, and then copy the associated address (from column 2 of the Addresses worksheet) to column 3 of the Inventory worksheet.

    File Inventory - Addresses.xlm is an example.

    Please Login or Register  to view this content.

    The macro works fine as long as the Serial Number being matched between both worksheets is exactly the same. However sometimes the Serial Number can slightly differ in the second worksheet, for example the Serial Number could be FOC09353DKS in the first worksheet while it could be listed as FOC09353DKS (123423) in the second worksheet. Hence I cannot retrieve the address for Serial Number FOC09353DKS

    How could I modify the above macro to search for a string (i.e. FOC09353DKS in this case) instead of matching a value?

    Note that actually it does not have to be done through a macro, I attempted to use something like =IF(ISERROR(VLOOKUP...) function without success.

    Thanks,
    Ant
    Attached Files Attached Files
    Last edited by Folshot; 05-06-2011 at 02:55 AM. Reason: Sorry, did not include [code] and [/code] for the code.

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Modifying macro to search for string instead of matching value.

    Hi Ant
    You can try this...it appears to do as you require
    Please Login or Register  to view this content.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

+ 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