+ Reply to Thread
Results 1 to 11 of 11

Application.Match help. Find a match if first 4 numbers are the same. Asterisk not working

  1. #1
    Registered User
    Join Date
    03-27-2013
    Location
    Long Island, NY
    MS-Off Ver
    Excel 2007
    Posts
    35

    Exclamation Application.Match help. Find a match if first 4 numbers are the same. Asterisk not working

    In my project, I am searching through a column that would have data as follows:
    B692.920
    A254.R30
    GN99.900
    AN49.TST
    etc. etc.

    I want to match the values with a column from another worksheet that would have the following:
    B692
    A254
    GN99

    If a match is not made, the row is to be hidden on the original sheet.
    The code works fine when i put the complete number in the column in the other sheet, however, I want to be able to match based upon just the first four.

    I have attached my code snippets below. The line highlighted in red is my issue. I have tried
    Please Login or Register  to view this content.
    and
    Please Login or Register  to view this content.
    Both to no avail, hiding all of my rows.

    Please Login or Register  to view this content.
    Any ideas?!

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Application.Match help. Find a match if first 4 numbers are the same. Asterisk not wor

    Normally, I would insert a formula in an empty column on the DM sheet to evaluate all the rows all at once, then hide the unwanted rows with an Autofilter, this would not loop at all.

    But for your project, my first suggestion is instead of trying to Match, use the FIND method.

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

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

    Re: Application.Match help. Find a match if first 4 numbers are the same. Asterisk not wor

    Match function works with EXCACT match only.

  4. #4
    Registered User
    Join Date
    03-27-2013
    Location
    Long Island, NY
    MS-Off Ver
    Excel 2007
    Posts
    35

    Re: Application.Match help. Find a match if first 4 numbers are the same. Asterisk not wor

    Quote Originally Posted by AB33 View Post
    Match function works with EXCACT match only.
    On the MS website it has three variations of MATCH using 1, -1 and 0. It also says you can use "*" to match any sequence of characters and "?" to find any single character

  5. #5
    Registered User
    Join Date
    03-27-2013
    Location
    Long Island, NY
    MS-Off Ver
    Excel 2007
    Posts
    35

    Re: Application.Match help. Find a match if first 4 numbers are the same. Asterisk not wor

    Quote Originally Posted by JBeaucaire View Post
    Normally, I would insert a formula in an empty column on the DM sheet to evaluate all the rows all at once, then hide the unwanted rows with an Autofilter, this would not loop at all.

    But for your project, my first suggestion is instead of trying to Match, use the FIND method.

    Please Login or Register  to view this content.
    I am going to try your method. However your suggested method before it I do not think is plausible in my application. My macro first opens a file, then searches the file for specific constraints in certain columns and copies those rows onto appropriately labled tabs, "DM" being one of them, then it does a sort by a few different constraints, and then it implements the snippet i posted.

  6. #6
    Registered User
    Join Date
    03-27-2013
    Location
    Long Island, NY
    MS-Off Ver
    Excel 2007
    Posts
    35

    Re: Application.Match help. Find a match if first 4 numbers are the same. Asterisk not wor

    JBeaucaire, I used the following code and it hides all of my "DM" rows. Maybe I am not quite following/understanding the line i highlighted in red
    Please Login or Register  to view this content.
    Last edited by thelisa; 07-10-2013 at 10:54 AM.

  7. #7
    Registered User
    Join Date
    05-23-2013
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    36

    Re: Application.Match help. Find a match if first 4 numbers are the same. Asterisk not wor

    don't have time to code it, but if you use a trim function on the data you want to compare (only look at the first four characters) you should be able to find matches and hide if there not matching pretty easily.

  8. #8
    Registered User
    Join Date
    03-27-2013
    Location
    Long Island, NY
    MS-Off Ver
    Excel 2007
    Posts
    35

    Re: Application.Match help. Find a match if first 4 numbers are the same. Asterisk not wor

    Quote Originally Posted by blackspiral View Post
    don't have time to code it, but if you use a trim function on the data you want to compare (only look at the first four characters) you should be able to find matches and hide if there not matching pretty easily.
    This could work, however, I forgot to specify the user CAN enter the full number if they want(B692.920) or just the first 4. The numbers stand for project numbers, and sometimes we want to see specifics of a certain project or just the whole project.

  9. #9
    Registered User
    Join Date
    05-23-2013
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    36

    Re: Application.Match help. Find a match if first 4 numbers are the same. Asterisk not wor

    ok, so count the number of characters not including the "*" in the input. Then trim the values you search for matches with that many characters.

  10. #10
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Application.Match help. Find a match if first 4 numbers are the same. Asterisk not wor

    ok, enough guessing. Post a sample workbook with a usable set of data and a mockup of the desired RESULTS so we can see the goal. Plus looking at your data may reveal issues we don't know about any other way.

    Remember to desensitize the data without corrupting its ability to represent what needs to be evaluated.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

  11. #11
    Registered User
    Join Date
    03-27-2013
    Location
    Long Island, NY
    MS-Off Ver
    Excel 2007
    Posts
    35

    Re: Application.Match help. Find a match if first 4 numbers are the same. Asterisk not wor

    I ended up just going a different route. It is actually a lot easier and works better for my application. Thank you all for your help. Here is my code I am now using:
    Please Login or Register  to view this content.

+ 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