Consulting

Results 1 to 5 of 5

Thread: Filter for suffix [x] when a comparing file has _x suffix

  1. #1
    VBAX Newbie
    Joined
    Jan 2023
    Posts
    5
    Location

    Filter for suffix [x] when a comparing file has _x suffix

    I have two huge excel files, lets call them "to be fixed" and "check". The "to be fixed" contains some suffix that end on "_1" etc. or "[1]" etc. The "check" file, that I want to compare the first file to, only contains "_1" suffixes but SOME mean basically the same. So e.g. ERR_PI[1] is ERR_PI[1] in the "to be fixed" file but ERR_PI_1 in the "check" File and ERR_PVS_H_1 is the same in the "to be fixed" and "check" file.

    The final goal is to sort out every entry in "fixing" that isn't in "check". Any good ideas? I used VLOOKUP(x,y,1,TRUE) and FALSE but FALSE doesn't detect the difference in "[1]" VS "_1" etc. and TRUE returns entries that just begin with "ERR_" and calls it close enough.
    Last edited by tomtom91; 01-18-2023 at 09:02 AM.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Something like this?

    =OR(ISNUMBER(MATCH(B2,K:K,0)),ISNUMBER(MATCH(SUBSTITUTE(B2,"[1]","_1"),K:K,0)))

    You will need to adjust the cells and columns, and add the workbook names.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Newbie
    Joined
    Jan 2023
    Posts
    5
    Location
    Quote Originally Posted by Bob Phillips View Post
    Something like this?

    =OR(ISNUMBER(MATCH(B2,K:K,0)),ISNUMBER(MATCH(SUBSTITUTE(B2,"[1]","_1"),K:K,0)))

    You will need to adjust the cells and columns, and add the workbook names.
    Yes that works. But unfortunately just for "1". I have indexes going from 0 to x. Is there a way to search for indexes going from 0 to let's say 10 to be safe? Alternatively I can use 10 columns and do a comparison for indexes 0 to 10. Not very effective and I would prefer a all-in-one-solution. Or I guess a Micro and for loop is needed.

  4. #4
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,192
    Location
    Elaborating on Bob's formula, maybe the below would work.

    =OR(ISNUMBER(MATCH(B2,K:K,0)),ISNUMBER(MATCH(SUBSTITUTE(SUBSTITUTE(B2,"[","_"),"]",""),K:K,0)))
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved

    Excel 365, Version 2403, Build 17425.20146

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Building some more on this, should you have a set of values that are similar but not the same as another set, but not quite as well-formed as in georgiboy's suggestion, then you could try something like


    =OR(ISNUMBER(MATCH(B2,K:K,0)),ISNUMBER(MATCH(SUBSTITUTE(B2,{"[1]","[2]","{Z}"},{"_1","_2","!Z"}),K:K,0)))
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •