+ Reply to Thread
Results 1 to 9 of 9

match the correct team names of Database A into Database B

Hybrid View

  1. #1
    Registered User
    Join Date
    09-16-2023
    Location
    Spain
    MS-Off Ver
    365
    Posts
    42

    match the correct team names of Database A into Database B

    Hello Xelers,
    I face the issue, that I need to match 2 Databases with its team names.
    The names in Database A are the correct ones.
    The names in Database B needs to be exchanged with the correct names from Database A

    I put 3 samples in line 3,4 and 5 for better understanding.

    I am attaching the file "matches.xlsx"

    The order of the listed names in column A should not be chaged as the names will be copied (after the correct name is set) back into the original file.
    It can happen that names appear several times.

    It can also be that names do not have a match at all from database A

    Maybe a VBA can solve my query.

    Is there anyone who can hels tp solve this issue?

    Thank you very much in advance.
    Thomas
    Attached Files Attached Files
    Last edited by ThomasB61; 02-06-2025 at 03:32 AM. Reason: make it simpler

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,209

    Re: match the correct team names of Database A into Database B

    You cannot replace names with a formula. You'll need VBA for this. Shall I move the thread for you?

    You ought to provide at least 3 or 4 examples in the sample file - perhaps highlight the matching rows to show which data you want.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    09-16-2023
    Location
    Spain
    MS-Off Ver
    365
    Posts
    42

    Re: match the correct team names of Database A into Database B

    Hi Ali,
    I edited the psot and made it simpler.
    Would you mind moving the thread to its correct category?
    Thank you very much
    Thomas

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,209

    Re: match the correct team names of Database A into Database B

    These are fuzzy replacements, which can be tricky. I'm moving the thread for you now.

  5. #5
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,063

    Re: match the correct team names of Database A into Database B

    To provide a solution please tell us..
    If there are multiple matches for a club how to know which is correct?

    For example, if in Database B is Austria Klagenfurt does it match to Austria or to Klagenfurt?
    Because Austria Vienna might also match to Austria...
    Never use Merged Cells in Excel

  6. #6
    Registered User
    Join Date
    09-16-2023
    Location
    Spain
    MS-Off Ver
    365
    Posts
    42

    Re: match the correct team names of Database A into Database B

    Hello zbor,
    thanks for getting back.
    Database A holds the correct name (& spelling). So, if a team has several matches (found in Database B) it may not be important, as it only needs to change to its name found in Database A.

    In the example of "Austria Klagenfurt", you will find the name of "Klagenfurt" in Database A. That makes it clear which "Austria" it is...

    Thomas

  7. #7
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,063

    Re: match the correct team names of Database A into Database B

    It's clear to me but it's not clear to Excel..
    If it say Austria Klagenfurt I can set that it return last word, Klagenfurt.. But in other case, for example, Heidelberg United
    it will return United that is common word..

    There is no formula: return me logically sometimes first and sometimes second..

    In such fuzzy logic database I would suggest to create new table in sheet 2 where you will put all variations...

    For example:

    Kiffen             	Kiffen
    Aston Villa     	Aston Villa
    Atletico Madrid   	Atletico
    Austria Klagenfurt	Klagenfurt
    Heidelberg United	Heidelberg
    In that case you will be able to VLOOKUP all names

  8. #8
    Registered User
    Join Date
    09-16-2023
    Location
    Spain
    MS-Off Ver
    365
    Posts
    42

    Re: match the correct team names of Database A into Database B

    Yes, I was thinking about that too, but since the table is 3000+ rows, it is a lot of work. Though, if there is no solution, then I might have to do just that.
    Thomas

  9. #9
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: match the correct team names of Database A into Database B

    Don't give up just yet...
    Let's first check what possible matches there are up to 2...
    Look at results here and then we can get some feedback and possibly refine to get as close as...

    There are members proficient in Regex which could get this perfected...Sadly I am not one of them...

    Sub J3v16()
    Dim Data, Chk, Str, Crit, Dict As Object, Fnd As Boolean, lr As Long, i As Long, ii As Long
    Set Dict = CreateObject("Scripting.Dictionary")
    lr = Cells(Rows.Count, 1).End(xlUp).Row
    With Cells(7, 1).CurrentRegion.Resize(, 5)
        .Cells(2, 2).Resize(lr, 3).ClearContents
        Data = .Value
        For i = 2 To UBound(Data)
          Dict.Item(Data(i, 5)) = 1
        Next i
        For i = 2 To lr
            If Dict.Exists(Data(i, 1)) Then
                Data(i, 2) = Data(i, 1): Fnd = True
            Else
                Fnd = False
                Str = Split(Data(i, 1), " ")
                If UBound(Str) > 0 Then
                    For ii = 0 To UBound(Str)
                        If Len(Str(ii)) > 2 Then
                            Crit = IIf(ii = 0, Str(ii) & "*", "*" & Str(ii) & "*")
                            Chk = Application.Match(Crit, .Columns(5), 0)
                            If Not IsError(Chk) Then
                                Data(i, 3) = Data(Chk, 5)
                                Fnd = True
                                Exit For
                            End If
                        End If
                    Next ii
                Else
                    Data(i, 2) = "NO MATCH"
                End If
                If Fnd = False Then Data(i, 2) = "NO MATCH"
            End If
        Next i
        .Value = Data
    End With
    End Sub
    Attached Files Attached Files
    Last edited by Sintek; 02-06-2025 at 11:53 AM.
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. random team making from database of player and ratings
    By wydim in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-10-2016, 09:35 AM
  2. Cannot get correct data from database
    By Rudzuks in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-23-2015, 02:46 AM
  3. Replies: 2
    Last Post: 10-22-2014, 11:32 PM
  4. Replies: 11
    Last Post: 10-21-2012, 01:40 AM
  5. Match data between CSV and database and update column in database table
    By djfscouse in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-05-2012, 05:59 PM
  6. Importing Text (csv) table to correct database
    By climoc in forum Access Programming / VBA / Macros
    Replies: 1
    Last Post: 10-26-2011, 01:17 PM
  7. Importing csv to correct database
    By climoc in forum Access Programming / VBA / Macros
    Replies: 2
    Last Post: 10-26-2011, 11:33 AM

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